model_server/gala/src/SpreadSheet.cxx
// Send access command to aset synchronically. This function is only used by Unix version.
Send access command to aset synchronically. This function is only used by Unix version.
Send access command to aset synchronically . This function is only used by Unix version .
int SendToServer_sync(char *msg, gString& retval)
{
    int fdread = 3;
    int fdwrite = 4;
    int len;
    char head[5];
    head[0] = '\4';
    if(write(fdwrite, head, 1) != 1) {
        printf("Error: write head failed\n");
        return 0;
    }
    int ok = 1;
    len = strlen(msg);
    if(write(fdwrite, msg, len + 1) == len + 1) {
	char buffer[1025];
        int nbyte, msglen = 0, recvlen = 0, gotsize = 0;
        do {
            do {
	      nbyte = read(fdread, buffer, sizeof(buffer) - 1);
	    } while ((errno == EINTR) && (nbyte < 0));
            if (nbyte >= 0) {
              buffer[nbyte] = '\0';
              if (!gotsize) {
                int headlen = strlen(buffer);
                if ((headlen > 0) && (headlen < (sizeof(buffer) - 1))) {
                  msglen = atoi(buffer);
                  if (msglen >= 0) {
                    recvlen += (nbyte - headlen) - 1;
                    retval += buffer + headlen + 1;
                    gotsize = 1;
		  } else {
                    printf("Error: message header from server contains invalid length\n");
                    ok = 0;
		  }
	        } else {
                  printf("Error: message header from server is corrupt\n");
                  ok = 0;
	        }
	      } else {
                recvlen += nbyte;
                retval += buffer;
	      }
	    } else {
              printf("Error: failed to read from server\n");
              ok = 0;
	    }
	} while ((recvlen < msglen) && ok);
    } else {
        printf("Error: write command error\n");
        ok = 0;
    }
    return ok;
}
int SendToServer_sync ( char * msg , gString & retval ) { int fdread = 3 ; int fdwrite = 4 ; int len ; char head [ 5 ] ; head [ 0 ] = ' \4 ' ; if ( write ( fdwrite , head , 1 ) != 1 ) { printf ( " \n " ) ; return 0 ; } int ok = 1 ; len = strlen ( msg ) ; if ( write ( fdwrite , msg , len + 1 ) == len + 1 ) { char buffer [ 1025 ] ; int nbyte , msglen = 0 , recvlen = 0 , gotsize = 0 ; do { do { nbyte = read ( fdread , buffer , sizeof ( buffer ) - 1 ) ; } while ( ( errno == EINTR ) && ( nbyte < 0 ) ) ; if ( nbyte >= 0 ) { buffer [ nbyte ] = ' \0 ' ; if ( ! gotsize ) { int headlen = strlen ( buffer ) ; if ( ( headlen > 0 ) && ( headlen < ( sizeof ( buffer ) - 1 ) ) ) { msglen = atoi ( buffer ) ; if ( msglen >= 0 ) { recvlen += ( nbyte - headlen ) - 1 ; retval += buffer + headlen + 1 ; gotsize = 1 ; } else { printf ( " \n " ) ; ok = 0 ; } } else { printf ( " \n " ) ; ok = 0 ; } } else { recvlen += nbyte ; retval += buffer ; } } else { printf ( " \n " ) ; ok = 0 ; } } while ( ( recvlen < msglen ) && ok ) ; } else { printf ( " \n " ) ; ok = 0 ; } return ok ; }
Send access command to aset synchronically.
Send access command to aset synchronically .
// For standard I/O:  fdread = 0, fdwrite = 1 // For 2waypipe:      fdread = 3, fdwrite = 4