jpegphoto.c

来自「ftam等标准协议服务器和客户端的源代码。」· C语言 代码 · 共 171 行

C
171
字号
/* jpegphoto.c - your comments here */#ifndef	lintstatic char *rcsid = "$Header: /xtel/isode/isode/others/quipu/photo/RCS/jpegphoto.c,v 9.0 1992/06/16 12:43:35 isode Rel $";#endif/*  * $Header: /xtel/isode/isode/others/quipu/photo/RCS/jpegphoto.c,v 9.0 1992/06/16 12:43:35 isode Rel $ * * * $Log: jpegphoto.c,v $ * Revision 9.0  1992/06/16  12:43:35  isode * Release 8.0 * *//* *				  NOTICE * *    Acquisition, use, and distribution of this module and related *    materials are subject to the restrictions of a license agreement. *    Consult the Preface in the User's Manual for the full terms of *    this agreement. * *//* * * jpegphoto- Read standard input and pipe output to correct displayer * * Russ Wright - Lawrence Berkeley Laboratory-  Oct 1991 */#include <stdio.h>#include "tailor.h"#include "general.h"#include "jpeg.h"#include <signal.h>#define BAD_EXIT        -1char            command[512];intmygetchar(){    char            c;    if (!read(0, &c, 1))        return (EOF);    else        return (c);}/* * SkipAsn1Len - skip the ASN-1 encoded length (variable # of octets) */voidSkipAsn1Len(){    unsigned char   c;    c = mygetchar();    if (c > 0x80)    {        c &= ~0x80;        while (c--)        {            (void) mygetchar();        }    }}voidDoG3Fax(firstChar)unsigned char firstChar;{    char            buffer[8192];    FILE           *newPipe;    int             len;    (void) strncpy(command, isodefile("g3fax/Xphoto", 1), sizeof(command) - 1);        (void) fprintf(stderr, "command IS '%s' ", command);    newPipe = popen(command, "w");    if (newPipe == NULL)    {        (void) fprintf(stderr, "command '%s' failed", command);        perror(" ");        exit(BAD_EXIT);    }    (void) fwrite((char *)&firstChar, 1, 1, newPipe);    while (len = read(0, buffer, sizeof(buffer)))    {        if (!fwrite(buffer, 1, len, newPipe))        {            (void) fprintf(stderr, "write to pipe failed for '%s'", command);            perror(" ");            exit(BAD_EXIT);        }    }    (void) pclose(newPipe);    exit(0);}voidDoNewJPEG(){    SkipAsn1Len();    (void) strncpy(command, isodefile("g3fax/jpeg.sh", 1), sizeof(command) - 1);    if (execl(command, "xphoto-jpeg", 0))    {        (void) fprintf(stderr, "command '%s' failed", command);        perror(" ");        exit(BAD_EXIT);    }/*NOTREACHED*/}voidDoJPEG(){    SkipAsn1Len();    (void) strncpy(command, isodefile("g3fax/jpeg.sh", 1), sizeof(command) - 1);    if (execl(command, "xphoto-jpeg", 0))    {        (void) fprintf(stderr, "command '%s' failed", command);        perror(" ");        exit(BAD_EXIT);    }/*NOTREACHED*/}/* ARGSUSED */voidmain(argc, argv, envp)int             argc;char          **argv,              **envp;{    unsigned char   firstChar;    firstChar = mygetchar();    /* test first octet */    switch (firstChar)    {    case NEW_JPEG_TAG:        DoNewJPEG();        break;    case JPEG_TAG:        DoJPEG();        break;    case OLD_G3Fax_TAG:    case G3Fax_TAG:        DoG3Fax(firstChar);        break;    default:        (void) fprintf(stderr, "Unknown Photo Format: %d\n", firstChar);        exit(BAD_EXIT);    }/*NOTREACHED*/}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?