• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

contrib/maloc/src/vsys/ziofb.c

00001 /*
00002  * ***************************************************************************
00003  * MALOC = < Minimal Abstraction Layer for Object-oriented C >
00004  * Copyright (C) 1994--2008 Michael Holst
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00019  *
00020  * rcsid="$Id: ziofb.c,v 1.16 2008/03/12 05:13:59 fetk Exp $"
00021  * ***************************************************************************
00022  */
00023 
00024 /*
00025  * ***************************************************************************
00026  * File:     ziofb.c
00027  *
00028  * Purpose:  FORTRAN bindings for the Vio class methods.
00029  *
00030  * Notes:    We provide FORTRAN stubs for the following manglings:
00031  *
00032  *               vrnd   --> no underscore,     lowercase (default)
00033  *               VRND   --> no underscore,     uppercase
00034  *               vrnd_  --> single underscore, lowercase
00035  *               VRND_  --> single underscore, uppercase
00036  *               vrnd__ --> double underscore, lowercase
00037  *               VRND__ --> double underscore, uppercase
00038  *
00039  * Author:   Michael Holst
00040  * ***************************************************************************
00041  */
00042 
00043 #include "vio_p.h"
00044 
00045 VEMBED(rcsid="$Id: ziofb.c,v 1.16 2008/03/12 05:13:59 fetk Exp $")
00046 
00047 /*
00048  * ***************************************************************************
00049  * Class Vio FORTRAN binding prototypes (default: no underscore, lowercase)
00050  * ***************************************************************************
00051  */
00052 
00053 VEXTERNC void ziosta(void);
00054 VEXTERNC void ziostp(void);
00055 VEXTERNC void zioctr(Vio *sock,
00056     char type[4], char frmt[3], 
00057     char *host, int *lenh, char *file, int *lenf,
00058     char mode[1], int *iflag);
00059 VEXTERNC void ziodtr(Vio *sock, int *iflag);
00060 VEXTERNC void zioutl(Vio *sock, char mode[1], int *iflag);
00061 VEXTERNC void zioint(Vio *sock, int *ival, int *len);
00062 VEXTERNC void zioflt(Vio *sock, float *fval, int *len);
00063 VEXTERNC void ziodbl(Vio *sock, double *dval, int *len);
00064 VEXTERNC void ziostr(Vio *sock, char *sval, int *len);
00065 
00066 /*
00067  * ***************************************************************************
00068  * Class Vio FORTRAN bindings
00069  * ***************************************************************************
00070  */
00071 
00072 /*
00073  * ***************************************************************************
00074  * Routine:  ziosta
00075  *
00076  * Purpose:  Start the Vio communication layer.
00077  *
00078  * Author:   Michael Holst
00079  * ***************************************************************************
00080  */
00081 VPUBLIC void ziosta(void)
00082 {
00083     Vio_start();
00084 }
00085 
00086 /*
00087  * ***************************************************************************
00088  * Routine:  ziostp
00089  *
00090  * Purpose:  Stop the Vio communication layer.
00091  *
00092  * Author:   Michael Holst
00093  * ***************************************************************************
00094  */
00095 VPUBLIC void ziostp(void)
00096 {
00097     Vio_stop();
00098 }
00099 
00100 /*
00101  * ***************************************************************************
00102  * Routine:  zioctr
00103  *
00104  * Purpose:  Construct the Vio object.
00105  *
00106  * Author:   Michael Holst
00107  * ***************************************************************************
00108  */
00109 VPUBLIC void zioctr(Vio *sock,
00110     char type[4], char frmt[3],
00111     char *host, int *lenh, char *file, int *lenf,
00112     char mode[1], int *iflag)
00113 {
00114     int i;
00115     char phost[VMAX_ARGLEN], pfile[VMAX_ARGLEN], ptype[VMAX_ARGLEN];
00116     char pfrmt[VMAX_ARGLEN], pmode[VMAX_ARGLEN];
00117 
00118 #if 0
00119     Vio sockSize;
00120     fprintf(stderr,"zioctr: Vio structure size is exactly <%d> bytes.\n",
00121         sizeof(sockSize) );
00122 #endif
00123 
00124     for (i=0; i<4; i++) ptype[i] = type[i];
00125     ptype[4] = '\0';
00126     for (i=0; i<3; i++) pfrmt[i] = frmt[i];
00127     pfrmt[3] = '\0';
00128     for (i=0; i<*lenh; i++) phost[i] = host[i];
00129     phost[*lenh] = '\0';
00130     for (i=0; i<*lenf; i++) pfile[i] = file[i];
00131     pfile[*lenf] = '\0';
00132     pmode[0] = mode[0];
00133     pmode[1] = '\0';
00134 
00135     VJMPERR1(0 != Vio_ctor2(sock, ptype, pfrmt, phost, pfile, pmode));
00136 
00137     *iflag = 0;
00138     return;
00139 
00140   VERROR1:
00141     *iflag = 1;
00142     return;
00143 }
00144 
00145 /*
00146  * ***************************************************************************
00147  * Routine:  ziodtr
00148  *
00149  * Purpose:  Destruct the Vio object.
00150  *
00151  * Author:   Michael Holst
00152  * ***************************************************************************
00153  */
00154 VPUBLIC void ziodtr(Vio *sock, int *iflag)
00155 {
00156     Vio_dtor2(sock);
00157     *iflag = 0;
00158     return;
00159 }
00160 
00161 /*
00162  * ***************************************************************************
00163  * Routine:  zioutl
00164  *
00165  * Purpose:  Vio state utility.
00166  *
00167  * Author:   Michael Holst
00168  * ***************************************************************************
00169  */
00170 VPUBLIC void zioutl(Vio *sock, char mode[1], int *iflag)
00171 {
00172     char pmode[VMAX_ARGLEN];
00173 
00174     pmode[0] = mode[0];
00175     pmode[1] = '\0';
00176 
00177     if ( !strcmp(pmode,"o") ) {
00178 
00179         if ( sock->rwkey == VIO_R ) {
00180             /* BLOCKING READ (blocking accept) */
00181             VJMPERR1( 0 <= Vio_accept(sock,0) );
00182         } else if ( sock->rwkey == VIO_W ) {
00183             /* BLOCKING WRITE (blocking connect) */
00184             VJMPERR1( 0 <= Vio_connect(sock,0) );
00185         } else { VJMPERR1(0); }
00186 
00187         *iflag = 0;
00188         return;
00189 
00190     } else if (!strcmp(pmode,"c")) {
00191 
00192         if ( sock->rwkey == VIO_R ) {
00193             Vio_acceptFree(sock);
00194         } else if ( sock->rwkey == VIO_W ) {
00195             Vio_connectFree(sock);
00196         } else { VJMPERR1(0); }
00197 
00198         *iflag = 0;
00199         return;
00200 
00201     } else { VJMPERR1(0); }
00202 
00203   VERROR1:
00204     *iflag = 1;
00205     return;
00206 }
00207 
00208 /*
00209  * ***************************************************************************
00210  * Routine:  zioint
00211  *
00212  * Purpose:  Integer READ/WRITE.
00213  *
00214  * Author:   Michael Holst
00215  * ***************************************************************************
00216  */
00217 VPUBLIC void zioint(Vio *sock, int *ival, int *len)
00218 {
00219     int i;
00220 
00221     if ( sock->rwkey == VIO_R ) {
00222         for (i=0; i<*len; i++)
00223             Vio_scanf(sock,"%d",&(ival[i]));
00224     } else if ( sock->rwkey == VIO_W ) {
00225         for (i=0; i<*len; i++)
00226             Vio_printf(sock,"%d ",ival[i]);
00227         Vio_printf(sock,"\n");
00228     }
00229 }
00230 
00231 /*
00232  * ***************************************************************************
00233  * Routine:  zioflt
00234  *
00235  * Purpose:  Float READ/WRITE.
00236  *
00237  * Author:   Michael Holst
00238  * ***************************************************************************
00239  */
00240 VPUBLIC void zioflt(Vio *sock, float *fval, int *len)
00241 {
00242     int i;
00243 
00244     if ( sock->rwkey == VIO_R ) {
00245         for (i=0; i<*len; i++)
00246             Vio_scanf(sock,"%e",&(fval[i]));
00247     } else if ( sock->rwkey == VIO_W ) {
00248         for (i=0; i<*len; i++)
00249             Vio_printf(sock,"%e ",fval[i]);
00250         Vio_printf(sock,"\n");
00251     }
00252 }
00253 
00254 /*
00255  * ***************************************************************************
00256  * Routine:  ziodbl
00257  *
00258  * Purpose:  Double READ/WRITE.
00259  *
00260  * Author:   Michael Holst
00261  * ***************************************************************************
00262  */
00263 VPUBLIC void ziodbl(Vio *sock, double *dval, int *len)
00264 {
00265     int i;
00266 
00267     if ( sock->rwkey == VIO_R ) {
00268         for (i=0; i<*len; i++)
00269             Vio_scanf(sock,"%le",&(dval[i]));
00270     } else if ( sock->rwkey == VIO_W ) {
00271         for (i=0; i<*len; i++)
00272             Vio_printf(sock,"%le ",dval[i]);
00273         Vio_printf(sock,"\n");
00274     }
00275 }
00276 
00277 /*
00278  * ***************************************************************************
00279  * Routine:  ziostr
00280  *
00281  * Purpose:  String READ/WRITE.
00282  *
00283  * Author:   Michael Holst
00284  * ***************************************************************************
00285  */
00286 VPUBLIC void ziostr(Vio *sock, char *sval, int *len)
00287 {
00288     int i;
00289     char buf[VMAX_BUFSIZE];
00290 
00291     if ( sock->rwkey == VIO_R ) {
00292         Vio_scanf(sock,"%s",buf);
00293         VASSERT( (int)strlen(buf) == *len );
00294         for (i=0; i<*len; i++) sval[i] = buf[i];
00295     } else if ( sock->rwkey == VIO_W ) {
00296         for (i=0; i<*len; i++) buf[i] = sval[i];
00297         buf[*len] = '\0';
00298         Vio_printf(sock,"%s\n",buf);
00299     }
00300 }
00301 
00302 /*
00303  * ***************************************************************************
00304  * Class Vio FORTRAN binding STUBS (no underscore, uppercase)
00305  * ***************************************************************************
00306  */
00307 
00308 VPUBLIC void ZIOSTA(void)
00309 {
00310     ziosta();
00311 }
00312 
00313 VPUBLIC void ZIOSTP(void)
00314 {
00315     ziostp();
00316 }
00317 
00318 VPUBLIC void ZIOCTR(Vio *sock,
00319     char type[4], char frmt[3], 
00320     char *host, int *lenh, char *file, int *lenf,
00321     char mode[1], int *iflag)
00322 {
00323     zioctr(sock, type, frmt, host, lenh, file, lenf, mode, iflag);
00324 }
00325 
00326 VPUBLIC void ZIODTR(Vio *sock, int *iflag)
00327 {
00328     ziodtr(sock, iflag);
00329 }
00330 
00331 VPUBLIC void ZIOUTL(Vio *sock, char mode[1], int *iflag)
00332 {
00333     zioutl(sock, mode, iflag);
00334 }
00335 
00336 VPUBLIC void ZIOINT(Vio *sock, int *ival, int *len)
00337 {
00338     zioint(sock, ival, len);
00339 }
00340 
00341 VPUBLIC void ZIOFLT(Vio *sock, float *fval, int *len)
00342 {
00343     zioflt(sock, fval, len);
00344 }
00345 
00346 VPUBLIC void ZIODBL(Vio *sock, double *dval, int *len)
00347 {
00348     ziodbl(sock, dval, len);
00349 }
00350 
00351 VPUBLIC void ZIOSTR(Vio *sock, char *sval, int *len)
00352 {
00353     ziostr(sock, sval, len);
00354 }
00355 
00356 /*
00357  * ***************************************************************************
00358  * Class Vio FORTRAN binding STUBS (single underscore, lowercase)
00359  * ***************************************************************************
00360  */
00361 
00362 VPUBLIC void ziosta_(void)
00363 {
00364     ziosta();
00365 }
00366 
00367 VPUBLIC void ziostp_(void)
00368 {
00369     ziostp();
00370 }
00371 
00372 VPUBLIC void zioctr_(Vio *sock,
00373     char type[4], char frmt[3], 
00374     char *host, int *lenh, char *file, int *lenf,
00375     char mode[1], int *iflag)
00376 {
00377     zioctr(sock, type, frmt, host, lenh, file, lenf, mode, iflag);
00378 }
00379 
00380 VPUBLIC void ziodtr_(Vio *sock, int *iflag)
00381 {
00382     ziodtr(sock, iflag);
00383 }
00384 
00385 VPUBLIC void zioutl_(Vio *sock, char mode[1], int *iflag)
00386 {
00387     zioutl(sock, mode, iflag);
00388 }
00389 
00390 VPUBLIC void zioint_(Vio *sock, int *ival, int *len)
00391 {
00392     zioint(sock, ival, len);
00393 }
00394 
00395 VPUBLIC void zioflt_(Vio *sock, float *fval, int *len)
00396 {
00397     zioflt(sock, fval, len);
00398 }
00399 
00400 VPUBLIC void ziodbl_(Vio *sock, double *dval, int *len)
00401 {
00402     ziodbl(sock, dval, len);
00403 }
00404 
00405 VPUBLIC void ziostr_(Vio *sock, char *sval, int *len)
00406 {
00407     ziostr(sock, sval, len);
00408 }
00409 
00410 /*
00411  * ***************************************************************************
00412  * Class Vio FORTRAN binding STUBS (single underscore, uppercase)
00413  * ***************************************************************************
00414  */
00415 
00416 VPUBLIC void ZIOSTA_(void)
00417 {
00418     ziosta();
00419 }
00420 
00421 VPUBLIC void ZIOSTP_(void)
00422 {
00423     ziostp();
00424 }
00425 
00426 VPUBLIC void ZIOCTR_(Vio *sock,
00427     char type[4], char frmt[3], 
00428     char *host, int *lenh, char *file, int *lenf,
00429     char mode[1], int *iflag)
00430 {
00431     zioctr(sock, type, frmt, host, lenh, file, lenf, mode, iflag);
00432 }
00433 
00434 VPUBLIC void ZIODTR_(Vio *sock, int *iflag)
00435 {
00436     ziodtr(sock, iflag);
00437 }
00438 
00439 VPUBLIC void ZIOUTL_(Vio *sock, char mode[1], int *iflag)
00440 {
00441     zioutl(sock, mode, iflag);
00442 }
00443 
00444 VPUBLIC void ZIOINT_(Vio *sock, int *ival, int *len)
00445 {
00446     zioint(sock, ival, len);
00447 }
00448 
00449 VPUBLIC void ZIOFLT_(Vio *sock, float *fval, int *len)
00450 {
00451     zioflt(sock, fval, len);
00452 }
00453 
00454 VPUBLIC void ZIODBL_(Vio *sock, double *dval, int *len)
00455 {
00456     ziodbl(sock, dval, len);
00457 }
00458 
00459 VPUBLIC void ZIOSTR_(Vio *sock, char *sval, int *len)
00460 {
00461     ziostr(sock, sval, len);
00462 }
00463 
00464 /*
00465  * ***************************************************************************
00466  * Class Vio FORTRAN binding STUBS (double underscore, lowercase)
00467  * ***************************************************************************
00468  */
00469 
00470 VPUBLIC void ziosta__(void)
00471 {
00472     ziosta();
00473 }
00474 
00475 VPUBLIC void ziostp__(void)
00476 {
00477     ziostp();
00478 }
00479 
00480 VPUBLIC void zioctr__(Vio *sock,
00481     char type[4], char frmt[3], 
00482     char *host, int *lenh, char *file, int *lenf,
00483     char mode[1], int *iflag)
00484 {
00485     zioctr(sock, type, frmt, host, lenh, file, lenf, mode, iflag);
00486 }
00487 
00488 VPUBLIC void ziodtr__(Vio *sock, int *iflag)
00489 {
00490     ziodtr(sock, iflag);
00491 }
00492 
00493 VPUBLIC void zioutl__(Vio *sock, char mode[1], int *iflag)
00494 {
00495     zioutl(sock, mode, iflag);
00496 }
00497 
00498 VPUBLIC void zioint__(Vio *sock, int *ival, int *len)
00499 {
00500     zioint(sock, ival, len);
00501 }
00502 
00503 VPUBLIC void zioflt__(Vio *sock, float *fval, int *len)
00504 {
00505     zioflt(sock, fval, len);
00506 }
00507 
00508 VPUBLIC void ziodbl__(Vio *sock, double *dval, int *len)
00509 {
00510     ziodbl(sock, dval, len);
00511 }
00512 
00513 VPUBLIC void ziostr__(Vio *sock, char *sval, int *len)
00514 {
00515     ziostr(sock, sval, len);
00516 }
00517 
00518 /*
00519  * ***************************************************************************
00520  * Class Vio FORTRAN binding STUBS (double underscore, uppercase)
00521  * ***************************************************************************
00522  */
00523 
00524 VPUBLIC void ZIOSTA__(void)
00525 {
00526     ziosta();
00527 }
00528 
00529 VPUBLIC void ZIOSTP__(void)
00530 {
00531     ziostp();
00532 }
00533 
00534 VPUBLIC void ZIOCTR__(Vio *sock,
00535     char type[4], char frmt[3], 
00536     char *host, int *lenh, char *file, int *lenf,
00537     char mode[1], int *iflag)
00538 {
00539     zioctr(sock, type, frmt, host, lenh, file, lenf, mode, iflag);
00540 }
00541 
00542 VPUBLIC void ZIODTR__(Vio *sock, int *iflag)
00543 {
00544     ziodtr(sock, iflag);
00545 }
00546 
00547 VPUBLIC void ZIOUTL__(Vio *sock, char mode[1], int *iflag)
00548 {
00549     zioutl(sock, mode, iflag);
00550 }
00551 
00552 VPUBLIC void ZIOINT__(Vio *sock, int *ival, int *len)
00553 {
00554     zioint(sock, ival, len);
00555 }
00556 
00557 VPUBLIC void ZIOFLT__(Vio *sock, float *fval, int *len)
00558 {
00559     zioflt(sock, fval, len);
00560 }
00561 
00562 VPUBLIC void ZIODBL__(Vio *sock, double *dval, int *len)
00563 {
00564     ziodbl(sock, dval, len);
00565 }
00566 
00567 VPUBLIC void ZIOSTR__(Vio *sock, char *sval, int *len)
00568 {
00569     ziostr(sock, sval, len);
00570 }
00571 

Generated on Wed Oct 20 2010 11:12:15 for APBS by  doxygen 1.7.2