예제 #1
0
파일: util.c 프로젝트: mingpen/OpenNT
LPTSTR Make8dot3Name( LPTSTR pSourceName )
{
    LPTSTR p, pName;
    TCHAR NameBuffer[MAX_PRINTER_NAME_LEN+MAX_SHARE_NAME_LEN+1];
    LPTSTR p8dot3Name = NULL;

    pName = pSourceName;

    /* Skip initial blanks:
     */
    while( *pName && ( *pName == SPACE ) )
        pName++;

    /* Skip over all backslashes:
     */
    if( p = _tcsrchr( pName, BACKSLASH ) )
    {
        /* If there's another character after the backslash,
         * make that the first character of the name:
         */
        if( *(p+1) )
        {
            pName = p+1;
        }

        /* Try to find another string before the backslash:
         */
        else
        {
            /* Back through any backslashes at the end of the name:
             */
            while( ( *p == BACKSLASH ) && ( p > pName ) )
                p--;

            /* Back up to any preceding backslash or the beginning
             * of the name:
             */
            while( ( *p != BACKSLASH ) && ( p > pName ) )
                p--;

            if( *p == BACKSLASH )
                p++;

            pName = p;
        }
    }

    /* Copy the complete name:
     */
    _tcscpy( NameBuffer, pName );

    StripBlanks( NameBuffer );

    NameBuffer[8] = NULLC;

    FreeSplStr( pSourceName );
    return AllocSplStr( NameBuffer );
}
예제 #2
0
파일: bmenu2.c 프로젝트: epicsdeb/rtems
void ProcessFile2(
  FILE	*infile,
  FILE	*outfile
)
{
   int             index;

   /*
    *  Read the file into our internal data structure
    */

   if ( Verbose )
     printf( "Processing (%s) -> (%s)\n", "stdin", "stdout" );

   ReadFileIntoChain2( infile );

   if ( Verbose )
     fprintf( stderr, "-------->FILE READ IN\n" );

   /*
    *  Remove any spaces before the keyword and mark each keyword line as
    *  such.  Also remove extra white space at the end of lines.
    */

   StripBlanks();

   if ( Verbose )
     fprintf( stderr, "-------->BLANKS BEFORE KEYWORDS STRIPPED\n" );


   FormatToTexinfo();

   if ( Verbose )
     fprintf( stderr, "-------->FILE FORMATTED TO TEXINFO\n" );

   /*
    *  Print the file
    */

   PrintFile2( outfile );

   if ( Verbose )
     fprintf( stderr, "-------->FILE PRINTED\n" );

   /*
    *  Clean Up
    */

   ReleaseFile();

   if ( Verbose )
     fprintf( stderr, "-------->FILE RELEASED\n" );
}
예제 #3
0
파일: str.c 프로젝트: Ethylix/child
char *SeperateWord(char *sentence)
{
    if (sentence == NULL)
        return NULL;

    while (*sentence != ' ' && *sentence != '\0' && *sentence != '\n')
        sentence++;

    if (*sentence == '\0' || *sentence == '\n') {
        *sentence = '\0';
        return (NULL);
    }

    if (*sentence == ' ') {
        *sentence = '\0';
        sentence++;
    }

    return (StripBlanks(sentence));
}
예제 #4
0
파일: filter.c 프로젝트: Ethylix/child
struct ruleset *add_rule (char *ruledata)
{
    struct ruleset ruleset;
    memset(&ruleset, 0, sizeof(ruleset));

    char *what, *direction, *stuff;
    char temp[1024];
    strncpy(temp, ruledata, 1023);
    what = temp;
    direction = SeperateWord(what);
    stuff = SeperateWord(direction);

    if (strempty(what) || strempty(direction))
        return NULL;

    if (!strcmp(what,"drop"))
        ruleset.rule = RULE_DROP;
    else if (!strcmp(what,"pass"))
        ruleset.rule = RULE_PASS;
    else
        return NULL;

    if (!strcmp(direction,"in"))
        ruleset.direction = DIRECT_IN;
    else if (!strcmp(direction,"out"))
        ruleset.direction = DIRECT_OUT;
    else
        return NULL;

    char *param, *data;
    param = stuff;
    stuff = SeperateWord(param);

    if (!strcmp(param, "quick")) {
        ruleset.quick = 1;
        param = stuff;
        stuff = SeperateWord(param);
    }

    for (; stuff; param = stuff, stuff = SeperateWord(stuff)) {
        if (strcmp(param, "data")) { /* not data */
            data = stuff;
            stuff = SeperateWord(data);
            if (strempty(data))
                return NULL;
            if (!strcmp(param, "from"))
                strncpy(ruleset.from, data, 32);
            else if (!strcmp(param, "to")) {
                if (*data == '\\' && *(data+1) == '#')
                    data++;
                strncpy(ruleset.to, data, 32);
            } else if (!strcmp(param, "action"))
                strncpy(ruleset.action, data, 32);
            else
                return NULL;
        } else {
            data = strchr(stuff, '"');
            if (strempty(data))
                return NULL;
            data++;
            char *tmp = strchr(data, '"');
            if (strempty(tmp))
                return NULL;
            *tmp = '\0';
            if (*(tmp+1) == 'i')
                ruleset.icase = 1;
            stuff = StripBlanks(tmp+1);
            strncpy(ruleset.data, data, 1024);
        }
    }

    struct ruleset *new_rule;
    new_rule = (struct ruleset *)calloc(1, sizeof(struct ruleset));
    memcpy(new_rule, &ruleset, sizeof(ruleset));
    LIST_INSERT_HEAD(rule_list, new_rule, HASH_INT(new_rule->direction));
    if (rule_list.size == 1)
        rule_list.ltail = new_rule;

    return new_rule;
}
예제 #5
0
파일: pp.c 프로젝트: kcrazy/winekit
/*++

Routine Description: GetPortSettings

    Read in port settings from the system

Arguments:

    DialogHwnd:      address of the window
    ComName: the port we're dealing with
    Params:      where to put the information we're getting

Return Value:

    ULONG: returns error messages

--*/
void
GetPortSettings(
    IN HWND             DialogHwnd,
    IN LPCTSTR           ComName,
    IN PPORT_PARAMS     Params
    )
{
    TCHAR  szParms[81];
    PTCHAR szCur, szNext;
    int    nIndex;

    //
    // read settings in from system
   //
    GetProfileString(m_szPorts,
                     ComName,
                     g_szNull,
                     szParms,
                     81);

    StripBlanks(szParms);
    if (lstrlen(szParms) == 0) 
    {
        StringCchCopy(szParms, ARRAYSIZE(szParms), m_szDefParams);
        WriteProfileString(m_szPorts, ComName, szParms);
    }

    szCur = szParms;

    //
    //  baud rate
    //
    szNext = strscan(szCur, m_szComma);
    if (*szNext) {
        //
        // If we found a comma, terminate
        //
        *szNext++ = 0;
    }

    //
    // current Baud Rate selection
    //
    if (*szCur) {
        Params->PortSettings.BaudRate = myatoi(szCur);
    }
    else {
        //
        // must not have been written, use default
        //
        Params->PortSettings.BaudRate = m_nBaudRates[DEF_BAUD];
    }

    //
    // set the current value in the dialog sheet
    //
    nIndex = (int)SendDlgItemMessage(DialogHwnd,
                                     PP_PORT_BAUDRATE,
                                     CB_FINDSTRING,
                                     (WPARAM)-1,
                                     (LPARAM)szCur);

    nIndex = (nIndex == CB_ERR) ? 0 : nIndex;

    SendDlgItemMessage(DialogHwnd,
                       PP_PORT_BAUDRATE,
                       CB_SETCURSEL,
                       nIndex,
                       0L);

    szCur = szNext;

    //
    //  parity
    //
    szNext = strscan(szCur, m_szComma);

    if (*szNext) {
        *szNext++ = 0;
    }
    StripBlanks(szCur);

    switch(*szCur) {
    case TEXT('o'):
        nIndex = PAR_ODD;
        break;

    case TEXT('e'):
        nIndex = PAR_EVEN;
        break;

    case TEXT('n'):
        nIndex = PAR_NONE;
        break;

    case TEXT('m'):
        nIndex = PAR_MARK;
        break;

    case TEXT('s'):
        nIndex = PAR_SPACE;
        break;

    default:
        nIndex = DEF_PARITY;
        break;
    }

    Params->PortSettings.Parity = nIndex;
    SendDlgItemMessage(DialogHwnd,
                       PP_PORT_PARITY,
                        CB_SETCURSEL,
                       nIndex,
                       0L);
    szCur = szNext;

    //
    //  word length: 4 - 8
    //
    szNext = strscan(szCur, m_szComma);

    if (*szNext) {
        *szNext++ = 0;
    }

    StripBlanks(szCur);
    nIndex = *szCur - TEXT('4');

    if (nIndex < 0 || nIndex > 4) {
        nIndex = DEF_WORD;
    }

    Params->PortSettings.DataBits = nIndex;
    SendDlgItemMessage(DialogHwnd,
                       PP_PORT_DATABITS,
                       CB_SETCURSEL,
                       nIndex,
                       0L);

    szCur = szNext;

    //
    //  stop bits
    //
    szNext = strscan(szCur, m_szComma);

    if (*szNext) {
       *szNext++ = 0;
    }

    StripBlanks(szCur);

    if (!lstrcmp(szCur, TEXT("1"))) {
        nIndex = STOP_1;
    }
    else if(!lstrcmp(szCur, TEXT("1.5"))) {
        nIndex = STOP_15;
    }
    else if(!lstrcmp(szCur, TEXT("2"))) {
        nIndex = STOP_2;
    }
    else {
        nIndex = DEF_STOP;
    }

    SendDlgItemMessage(DialogHwnd,
                       PP_PORT_STOPBITS,
                       CB_SETCURSEL,
                       nIndex,
                       0L);

    Params->PortSettings.StopBits = nIndex;
    szCur = szNext;

    //
    //  handshaking: Hardware, xon/xoff, or none
    //
    szNext = strscan(szCur, m_szComma);

    if (*szNext) {
        *szNext++ = 0;
    }

    StripBlanks(szCur);

    if (*szCur == TEXT('p')) {
        nIndex = FLOW_HARD;
    }
    else if (*szCur == TEXT('x')) {
        nIndex = FLOW_XON;
    }
    else {
        nIndex = FLOW_NONE;
    }

    SendDlgItemMessage(DialogHwnd,
                       PP_PORT_FLOWCTL,
                       CB_SETCURSEL,
                       nIndex,
                       0L);

    Params->PortSettings.FlowControl = nIndex;
} /* GetPortSettings */