コード例 #1
0
ファイル: processor.c プロジェクト: F0rth/seafile-obsd-wip
void ccnet_processor_handle_response (CcnetProcessor *processor, 
                                      char *code, char *code_msg,
                                      char *content, int clen)
{
    if ((code[0] == '5' || code[0] == '4') &&
        !CCNET_IS_KEEPALIVE2_PROC(processor))
    {
        ccnet_warning ("[Proc] peer %.10s, Shutdown processor %s(%d) for bad response: %s %s\n",
                       processor->peer->id, GET_PNAME(processor), PRINT_ID(processor->id),
                       code, code_msg);

        /* Stub proc should relay the message before it shuts down. */
        if (CCNET_IS_SERVICE_PROXY_PROC(processor) ||
            CCNET_IS_SERVICE_STUB_PROC(processor)) {
            CCNET_PROCESSOR_GET_CLASS (processor)->handle_response (
                processor, code, code_msg, content, clen);
        }

        if (memcmp(code, SC_UNKNOWN_SERVICE, 3) == 0)
            processor->failure = PROC_NO_SERVICE;
        else if (memcmp(code, SC_PERM_ERR, 3) == 0)
            processor->failure = PROC_PERM_ERR;
        else if (memcmp(code, SC_CON_TIMEOUT, 3) == 0)
            processor->failure = PROC_CON_TIMEOUT;
        else if (memcmp(code, SC_KEEPALIVE_TIMEOUT, 3) == 0)
            processor->failure = PROC_TIMEOUT;
        else if (memcmp(code, SC_NETDOWN, 3) == 0)
            processor->failure = PROC_NETDOWN;
        else
            processor->failure = PROC_BAD_RESP;

        ccnet_processor_done (processor, FALSE);

        return;
    }

    processor->t_packet_recv = time(NULL);

    if (memcmp (code, SC_PROC_KEEPALIVE, 3) == 0) {
        ccnet_processor_keep_alive_response (processor);
    } else if (memcmp (code, SC_PROC_ALIVE, 3) == 0) {
        /* do nothing */
    } else if (memcmp (code, SC_PROC_DEAD, 3) == 0) {
        ccnet_debug ("[Proc] Shutdown processor %s(%d) when remote processor dies\n",
                     GET_PNAME(processor), PRINT_ID(processor->id));

        if (CCNET_IS_SERVICE_PROXY_PROC(processor) ||
            CCNET_IS_SERVICE_STUB_PROC(processor)) {
            CCNET_PROCESSOR_GET_CLASS (processor)->handle_response (
                processor, code, code_msg, content, clen);
        }

        processor->failure = PROC_REMOTE_DEAD;
        ccnet_processor_done (processor, FALSE);
    } else
        CCNET_PROCESSOR_GET_CLASS (processor)->handle_response (processor,
                                                                code, code_msg, 
                                                                content, clen);
}
コード例 #2
0
ファイル: processor.c プロジェクト: aclindsa/ccnet
void
ccnet_processor_done (CcnetProcessor *processor,
                      gboolean success)
{
    if (processor->thread_running) {
        processor->delay_shutdown = TRUE;
        processor->was_success = success;
        return;
    }

    if (processor->state == STATE_IN_SHUTDOWN) {
        return;
    }
    processor->state = STATE_IN_SHUTDOWN;
    if (processor->failure == PROC_NOTSET && success)
        processor->failure = PROC_DONE;

    g_debug ("[proc] Processor %s(%d) done %d\n", GET_PNAME(processor),
             PRINT_ID(processor->id), success);

    /* Notify */
    if (!IS_SLAVE (processor) && success) {
        ccnet_processor_send_update (processor, SC_PROC_DONE, SS_PROC_DONE,
                                     NULL, 0);
    }

    g_signal_emit (processor, signals[DONE_SIG], 0, success);

    ccnet_client_remove_processor (processor->session, processor);
    ccnet_processor_release_resource (processor);
    ccnet_proc_factory_recycle (processor->session->proc_factory, processor);
}
コード例 #3
0
ファイル: ttarchive.c プロジェクト: TC01/gcc4ti
//=============================================================================
// outputs usage information of this tool
//=============================================================================
void PrintUsage() {
    PRINT_ID("TTArchive");
    fprintf(USAGE_OUT, "Usage: ttarchive [flags] <cfgfile> <varname> [folder]\n\n"\
                       "       -89            .... generate TI89 variable\n"\
                       "       -92            .... generate TI92p variable\n"\
                       "       -v             .... verbose (unsets -quiet)\n"\
                       "       -quiet         ...  don't output standard messages (unsets -v)\n"\
                       "       -e <extension> .... use special extension\n\n"\
                       "       cfgfile        .... configuration file to use\n"\
                       "       varname        .... on-calc variable name of output\n"\
                       "       folder         .... on-calc destination folder (OPTIONAL)\n\n"\
                       "       generates an archive file. The contents of the archive\n"\
                       "       have to be specified in a configfile where each line contains\n"\
                       "       one file which should be added to the archive.\n"\
                       "       An archive file can hold compressed or uncompressed entries.\n"\
                       "       If an entry should be compressed add tag \"compress\" at the\n"\
                       "       end of the config line.\n\n"\
                       "       [-------- format of one line in the configfile --------]\n"\
                       "       <file_to_store> <varname> <attr1> <attr2> [compress]\n\n"\
                       "       file_to_store ... name including path to inputfile\n"\
                       "       varname       ... name used to find data in archive (max. 8 chars)\n"\
                       "       attr1 attr2   ... misc. attributes which may be queried from program\n"\
                       "                           (0..65536)\n"\
                       "       compress      ... if this tag is set on the end of the line the\n"\
                       "                         given inputfile will be compressed before adding\n"\
                       "                         it to the archive\n\n");

}
コード例 #4
0
ファイル: ttsetname.c プロジェクト: TC01/gcc4ti
//=============================================================================
// outputs usage information of this tool
//=============================================================================
void PrintUsage() {
    PRINT_ID("TTSetName");
    fprintf(USAGE_OUT, "Usage: ttsetname [flags] file\n\n" \
                       "       -quit          ...  don't output standard messages\n"                    \
                       "       -name   string ...  set oncalc name to given string (max. 8 chars)\n"    \
                       "       -folder string ...  set oncalc folder to given string (max. 8 chars)\n\n"\
                       "       sets oncalc name and folder of given TI89/TI92p file\n");
}
コード例 #5
0
ファイル: processor.c プロジェクト: aclindsa/ccnet
void ccnet_processor_handle_update (CcnetProcessor *processor, 
                                    char *code, char *code_msg,
                                    char *content, int clen)
{
    g_object_ref (processor);
    processor->is_active = TRUE;

    if (code[0] == '5') {
        ccnet_warning ("[Proc] Shutdown processor %s(%d) for bad update: %s %s\n",
                       GET_PNAME(processor), PRINT_ID(processor->id),
                       code, code_msg);

        if (memcmp(code, SC_UNKNOWN_SERVICE, 3) == 0)
            processor->failure = PROC_NO_SERVICE;
        else if (memcmp(code, SC_PERM_ERR, 3) == 0)
            processor->failure = PROC_PERM_ERR;
        else if (memcmp(code, SC_NETDOWN, 3) == 0)
            processor->failure = PROC_REMOTE_DEAD;
        else
            processor->failure = PROC_BAD_RESP;

        ccnet_processor_done (processor, FALSE);
        return;
    }

    if (strncmp (code, SC_PROC_KEEPALIVE, 3) == 0) {
        ccnet_processor_send_response (processor, SC_PROC_ALIVE, 
                                       SS_PROC_ALIVE, NULL, 0);
    } else if (strncmp (code, SC_PROC_DEAD, 3) == 0) {
        g_warning ("[proc] Shutdown processor %s(%d) when peer(%.8s) processor is dead\n",
                   GET_PNAME(processor), PRINT_ID(processor->id),
                   processor->peer_id);
        processor->failure = PROC_REMOTE_DEAD;
        ccnet_processor_done (processor, FALSE);
    } else if (strncmp (code, SC_PROC_DONE, 3) == 0) {
        g_debug ("[proc] Shutdown processor when receive 103: service done\n");
        ccnet_processor_done (processor, TRUE);
    } else {
        CCNET_PROCESSOR_GET_CLASS (processor)->handle_update (processor, 
                                                              code, code_msg, 
                                                              content, clen);
    }
    processor->is_active = FALSE;
    g_object_unref (processor);
}
コード例 #6
0
ファイル: service-proxy-proc.c プロジェクト: 9thsector/ccnet
static void handle_response (CcnetProcessor *processor,
                             char *code, char *code_msg,
                             char *content, int clen)
{
    ServiceProxyPriv *priv = GET_PRIV (processor);
    if(!priv->stub_proc || !((CcnetProcessor *)priv->stub_proc)->peer->is_local)
        ccnet_debug ("[Svc Proxy] %s:%d [%s] handle response: %s %s\n",
                     GET_PNAME(processor), PRINT_ID(processor->id),
                     priv->name, code, code_msg);

    /* relay this response */
    ccnet_processor_send_response (processor, code, code_msg, content, clen);
}
コード例 #7
0
ファイル: processor.c プロジェクト: F0rth/seafile-obsd-wip
void
ccnet_processor_done (CcnetProcessor *processor, gboolean success)
{
    if (processor->thread_running) {
        processor->delay_shutdown = TRUE;
        processor->was_success = success;
        return;
    }

    if (processor->state == STATE_IN_SHUTDOWN) {
        return;
    }

    processor->state = STATE_IN_SHUTDOWN;
    if (processor->failure == PROC_NOTSET)
        processor->failure = PROC_DONE;
    if (!processor->peer->is_local)
        ccnet_debug ("Processsor %s(%d) done %d\n", GET_PNAME(processor),
                     PRINT_ID(processor->id), success);

    if (!processor->detached && success)
    {
        if (!IS_SLAVE (processor)) {
            ccnet_processor_send_update (processor, SC_PROC_DONE, SS_PROC_DONE,
                                         NULL, 0);
        }
    }

    /* When we emit the done signal, the corresponding handler may
     * shutdown the peer, we should remove this processor from the
     * peers processor list, otherwise this processor will be freed
     * twice. */
    g_signal_emit (processor, signals[DONE_SIG], 0, success);

    if (!processor->detached) {
        ccnet_peer_remove_processor (processor->peer, processor);
    }

    ccnet_processor_release_resource (processor);

    ccnet_proc_factory_recycle (processor->session->proc_factory, processor);
}
コード例 #8
0
ファイル: ttbin2oth.c プロジェクト: TC01/gcc4ti
//=============================================================================
// outputs usage information of this tool
//=============================================================================
void PrintUsage() {
#ifndef EMBEDDED_USE
    PRINT_ID("TTBin2OTH");
#endif
    fprintf(USAGE_OUT, "Usage: ttbin2oth [flags] <-89 | -92> <extension> <infile> <varname> [folder]\n\n" \
                       "       -quiet    ...  don't output standard messages\n"                           \
                       "       -strip    ...  MUST be set if the input is already a TI file\n"            \
                       "                      (generates a temporary file called bin2oth.tmp for\n"       \
                       "                      the stripped inputfile)\n"                                  \
                       "       -89       ...  generate a TI89 file\n"                                     \
                       "       -92       ...  generate a TI92p file\n\n"                                  \
                       "       extension ...  on-calc extension (up to 4 characters)\n"                   \
                       "       varname   ...  on-calc variable name (up to 8 characters)\n"               \
                       "       folder    ...  on-calc destination folder (OPTIONAL)\n\n"                  \
                       "       enwraps file into a custom TI89 or TI92p variable with given <extension>\n"\
                       "       NOTE1: the extension length may vary between 1 and 4 characters\n"         \
                       "       NOTE2: the output filename is generated by taking the given varname and\n" \
                       "              appending \".89y\" or \".9xy\" to it.\n"                            \
                       "       NOTE3: if a generated file CAN'T BE UPLOADED, you are probably using a\n"  \
                       "              reserved AMS name for your variable. Just try another name in\n"    \
                       "              this case.\n\n");
}
コード例 #9
0
ファイル: ttdos2ebk.c プロジェクト: TC01/gcc4ti
int main(int argc, char* argv[]) {
#else
int TTDos2Ebk(int argc,char* argv[]) {
#endif
    FILE*          fp = NULL;
    long           size;
    char* buf1 = NULL;
    char* buf2 = NULL;
    char* infile  = 0;
    char* outfile = 0;
    //int            replace = 1;
    int            verbose = 0;
    int            i;

#ifndef EMBEDDED_USE
    PRINT_ID("TTDos2EBK");
#endif

    if (argc < 3) {
#ifndef EMBEDDED_USE
        PrintUsage();
#endif
        return 1;
    }

    // parse arguments
    for (i=1; i<argc; i++) {
        if (!strcmp(argv[i], "-v")) verbose = 1;
        else if (!infile)  infile  = argv[i];
        else if (!outfile) outfile = argv[i];
        else {
#ifndef EMBEDDED_USE
            PrintUsage();
#endif
            return 1;
        }
    }

    if (!infile || !outfile) {
#ifndef EMBEDDED_USE
        PrintUsage();
#endif
        return 1;
    }


    if (!(fp = fopen(infile,"rb"))) {
        fprintf(stderr,"ERROR: cannot open inputfile %s\n",infile);
        return 1;
    }

    fseek(fp,0,SEEK_END);
    size = ftell(fp);
    rewind(fp);

    if (verbose) fprintf(stderr,"inputsize is %ld bytes\n",size);

    if (!(buf1 = malloc(size*2))) {   // size*2 necessary for double-space
        fprintf(stderr,"ERROR: cannot allocate %ld bytes\n",size);
        fclose(fp);
        free(buf2);
        free(buf1);
        return 1;
    }
    if (!(buf2 = malloc(size*2))) {   // size*2 necessary for double-space
        fprintf(stderr,"ERROR: cannot allocate %ld bytes\n",size);
        fclose(fp);
        free(buf2);
        free(buf1);
        return 1;
    }

    if (fread(buf1,size,1,fp) != 1) {
        fprintf(stderr,"ERROR: cannot read content of inputfile %s\n",infile);
        fclose(fp);
        free(buf2);
        free(buf1);
        return 1;
    }
    fclose(fp);

    if (!(fp = fopen(outfile,"wb"))) {
        fprintf(stderr,"ERROR: cannot open outputfile %s\n",outfile);
        free(buf2);
        free(buf1);
        return 1;
    }

    size = Translate(buf1,buf2,size);
    if (verbose) fprintf(stderr,"size after translation = %ld\n",size);

    size = RemoveAll0D(buf2,buf1,size);
    if (verbose) fprintf(stderr,"after removing all 0x0D is size %ld bytes\n",size);


    size = Preprocess(buf1,buf2,size,verbose);

    if (fwrite(buf2,size,1,fp) != 1) {
        fprintf(stderr,"ERROR: cannot write %ld bytes to outputfile %s\n",size,outfile);
    }
    else {
        if (verbose) fprintf(stderr,"%ld bytes written to file %s\n",size,outfile);
    }

    fclose(fp);
    free(buf2);
    free(buf1);

    return 0;
}
コード例 #10
0
ファイル: ttbin2oth.c プロジェクト: TC01/gcc4ti
int main(int argc,char *argv[]) {
#else
int TTBin2OTH(int argc,char *argv[]) {
#endif
    char*          infile    = NULL;
    char*          folder    = NULL;
    char*          name      = NULL;
    char*          extension = NULL;
    int            calctype  = -1;
    int            strip     = 0;
    FILE*          ifp;
    FILE*          ofp;
    char           outfile[1024];
    unsigned char* buffer;
    int            length;
    unsigned char* outbuffer;
    unsigned int   outlength;
    int            n;
    char*          tmpfilename = "bin2oth.tmp";
    int            quiet = 0;

    // check for too less arguments
    if (argc < 4) {
#ifndef EMBEDDED_USE
        PrintUsage();
#endif
        return 1;
    }

    // parse arguments
    for (n=1; n<argc; n++) {
        if (!strcmp(argv[n], "-89"))         calctype  = CALC_TI89;
        else if (!strcmp(argv[n], "-92"))    calctype  = CALC_TI92P;
        else if (!strcmp(argv[n], "-strip")) strip     = 1;
        else if (!strcmp(argv[n], "-quiet")) quiet     = 1;
        else if (argv[n][0] == '-') {
            fprintf(stderr,"ERROR: invalid option %s",argv[n]);
            return 1;
        }
        else if (!extension) extension = argv[n];
        else if (!infile)    infile    = argv[n];
        else if (!name)      name      = argv[n];
        else if (!folder)    folder    = argv[n];
        else {
#ifndef EMBEDDED_USE
            PrintUsage();
#endif
            return 1;
        }
    }

    // check if all necessary arguments are supplied
    if (!infile || !name || calctype == -1 || !extension) {
#ifndef EMBEDDED_USE
        PrintUsage();
#endif
        return 1;
    }

    n = strlen(extension);
    if (n<1 || n>4) {
        fprintf(stderr,"ERROR: extension length must be between 1 and 4 characters\n");
        return 1;
    }

    if (strip) {
        char* params[4];
        params[0] = "";
        params[1] = "-quiet";
        params[2] = infile;
        params[3] = tmpfilename;
        if (TTStrip(4,params)) {
            fprintf(stderr,"ERROR: stripping inputfile %s failed\n",infile);
            return 1;
        }
        infile = tmpfilename;
    }

#ifndef EMBEDDED_USE
    if (!quiet) PRINT_ID("TTBin2OTH");
#endif


    if (!(ifp = fopen(infile,"rb"))) {
        fprintf(stderr,"ERROR: cannot open inputfile %s\n",infile);
        if (strip) remove(tmpfilename);
        return 1;
    }

    if (calctype == CALC_TI89) sprintf(outfile,"%s.89y",name);
    else                       sprintf(outfile,"%s.9xy",name);

    if (!(ofp = fopen(outfile,"wb"))) {
        fprintf(stderr,"ERROR: cannot open outputfile %s\n",outfile);
        fclose(ifp);
        if (strip) remove(tmpfilename);
        return 1;
    }

    // read infile into buffer
    fseek(ifp,0,SEEK_END);
    length = ftell(ifp);
    buffer = (unsigned char*)malloc(length);
    if (!buffer) {
        fprintf(stderr,"ERROR: cannot allocate memory (%d bytes)\n",length);
        fclose(ifp);
        fclose(ofp);
        if (strip) remove(tmpfilename);
        return 1;
    }
    rewind(ifp);
    fread(buffer,1,length,ifp);
    fclose(ifp);

    outbuffer = DataBuffer2OTHBuffer(calctype,folder,name,extension,length,buffer,&outlength);

    n = 0;

    if (!outbuffer) {
        n = 1;
    }
    else {
        if (fwrite(outbuffer,outlength,1,ofp) != 1) {
            fprintf(stderr,"ERROR: cannot write %u bytes to outputfile to %s\n",outlength,outfile);
            n = 1;
        }
        else {
            if (!quiet) fprintf(stdout,"%u bytes written to %s\n",outlength,outfile);
        }
        free(outbuffer);
    }

    free(buffer);
    fclose(ofp);

    if (strip) remove(tmpfilename);
    return n;
}
コード例 #11
0
ファイル: ttsetname.c プロジェクト: TC01/gcc4ti
//=============================================================================
// ... just a stupid main ...
//=============================================================================
int main(int argc,char *argv[]) {
    char*          file   = NULL;
    char*          folder = NULL;
    char*          name   = NULL;
    FILE*          fp;
    int            n;
    int            quiet = 0;
    StrHeader      buffer;

    // parse arguments
    for (n=1; n<argc; n++) {
        if (!strcmp(argv[n], "-quiet")) quiet = 1;

        else if (!strcmp(argv[n], "-folder")) {
            if (n == argc -1) {
                fprintf(stderr,"ERROR: missing parameter for option '-folder'\n");
                return 1;
            }
            if (strlen(argv[n+1])>8) {
                fprintf(stderr,"ERROR: folder too long (max. 8 characters)\n");
                return 1;
            }
            folder = argv[n+1];
            n++;
        }
        else if (!strcmp(argv[n], "-name")) {
            if (n == argc -1) {
                fprintf(stderr,"ERROR: missing parameter for option '-name'\n");
                return 1;
            }

            if (strlen(argv[n+1])>8) {
                fprintf(stderr,"ERROR: name too long (max. 8 characters)\n");
                return 1;
            }
            name = argv[n+1];
            n++;
        }
        else if (argv[n][0] == '-') {
            fprintf(stderr,"ERROR: invalid option %s",argv[n]);
            return 1;
        }
        else if (!file) file = argv[n];
        else {
            PrintUsage();
            return 1;
        }
    }

    // check if all necessary arguments are supplied
    if (!file || (!name && !folder)) {
        PrintUsage();
        return 1;
    }

    if (!quiet) PRINT_ID("TTBin2OTH");

    if (!(fp = fopen(file,"rb+"))) {
        fprintf(stderr,"ERROR: cannot open file %s\n",file);
        return 1;
    }

    if (fread(&buffer,sizeof(StrHeader),1,fp) != 1) {
        fprintf(stderr,"ERROR: cannot read signature\n");
        fclose(fp);
        return 1;
    }

    if (strncmp(buffer.signature,SIGNATURE_TI89,8) && strncmp(buffer.signature,SIGNATURE_TI92P,8)) {
        fprintf(stderr,"ERROR: neither TI89 nor TI92p file\n");
        fclose(fp);
        return 1;
    }

    if (name) {
        memset(buffer.name,0,8);
        strncpy(buffer.name,name,8);
    }

    if (folder) {
        memset(buffer.folder,0,8);
        strncpy(buffer.folder,folder,8);
    }

    rewind(fp);
    if (fwrite(&buffer,sizeof(StrHeader),1,fp) != 1) {
        fprintf(stderr,"ERROR: cannot write to %s\n",file);
        fclose(fp);
        return 1;
    }
    fclose(fp);

    if (!quiet) {
        if (name) {
            fprintf(stderr,"file %s: new oncalc name = %s\n",file,name);
        }
        if (folder) {
            fprintf(stderr,"file %s: new oncalc folder = %s\n",file,folder);
        }
    }

    return 0;
}
コード例 #12
0
ファイル: ttarchive.c プロジェクト: TC01/gcc4ti
int main(int argc,char *argv[]) {
#else
int TTArchive(int argc,char *argv[]) {
#endif
    char*          folder    = NULL;
    char*          name      = NULL;
    char*          cfgname   = NULL;
    int            calctype  = -1;
    FILE*          ofp;
    char           outfile[1024];
    unsigned char* buffer;
    unsigned long  length;
    unsigned char* outbuffer;
    unsigned int   outlength;
    unsigned int   retval;
    char* extension = "tta";  // default extension
    int            n;
    int            verbose = 0;
    int            quiet   = 0;


    // check for too less arguments
    if (argc < 4) {
#ifndef EMBEDDED_USE
        PrintUsage();
#endif
        return 1;
    }

    // parse arguments
    for (n=1; n<argc; n++) {
        if (!strcmp(argv[n], "-89"))         calctype = CALC_TI89;
        else if (!strcmp(argv[n], "-92"))    calctype = CALC_TI92P;
        else if (!strcmp(argv[n], "-quiet")) verbose  = 0,quiet = 1;
        else if (!strcmp(argv[n], "-v"))     verbose  = 1,quiet = 0;
        else if (!strcmp(argv[n],"-e")) {
            if (n==argc-1) {
#ifndef EMBEDDED_USE
                PrintUsage();
#endif
                return 1;
            }
            else {
                int length;
                n++;
                extension = argv[n];
                length = strlen(extension);
                if (length < 1 || length > 4) {
                    fprintf(stderr,"ERROR: extension have to be between 1 and 4 characters\n");
                    return 1;
                }
            }
        }
        else if (argv[n][0] == '-') {
            fprintf(stderr,"ERROR: invalid option %s",argv[n]);
            return 1;
        }
        else if (!cfgname) cfgname = argv[n];
        else if (!name)    name    = argv[n];
        else if (!folder)  folder  = argv[n];
        else {
#ifndef EMBEDDED_USE
            PrintUsage();
#endif
            return 1;
        }
    }

    // check if all necessary arguments are supplied
    if (!cfgname || !name || calctype == -1) {
#ifndef EMBEDDED_USE
        PrintUsage();
#endif
        return 1;
    }


#ifndef EMBEDDED_USE
    if (!quiet) PRINT_ID("TTArchive");
#endif


    if (calctype == CALC_TI89) sprintf(outfile,"%s.89y",name);
    else                       sprintf(outfile,"%s.9xy",name);

    buffer = ProcessConfigFile(cfgname,&length,verbose);
    if (!buffer) return 1;


    if (!(ofp = fopen(outfile,"wb"))) {
        fprintf(stderr,"ERROR: cannot open outputfile %s\n",outfile);
        return 1;
    }

    outbuffer = DataBuffer2OTHBuffer(calctype,folder,name,extension,length,buffer,&outlength);

    retval = 0;

    if (!outbuffer) {
        retval = 1;
    }
    else {
        if (fwrite(outbuffer,outlength,1,ofp) != 1) {
            fprintf(stderr,"ERROR: cannot write %u bytes to %s\n",outlength,outfile);
            retval = 1;
        }
        else {
            if (!quiet) fprintf(stdout,"%u bytes written to %s\n",outlength,outfile);
        }
        free(outbuffer);
    }

    free(buffer);
    fclose(ofp);

    return retval;
}