C++ (Cpp) strlen Examples

C++ (Cpp) strlen - 30 examples found. These are the top rated real world C++ (Cpp) examples of strlen extracted from open source projects. You can rate examples to help us improve the quality of examples.
char *
XkbActionText(Display *dpy,XkbDescPtr xkb,XkbAction *action,unsigned format)
{
    char	buf[ACTION_SZ],*tmp;
    int	sz;

    if (format==XkbCFile) {
        sprintf(buf,
                "{ %20s, { 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x } }",
                XkbActionTypeText(action->type,XkbCFile),
                action->any.data[0],action->any.data[1],action->any.data[2],
                action->any.data[3],action->any.data[4],action->any.data[5],
                action->any.data[6]);
    }
    else {
        sprintf(buf,"%s(",XkbActionTypeText(action->type,XkbXKBFile));
        sz= ACTION_SZ-strlen(buf)+2; /* room for close paren and NULL */
        if (action->type<(unsigned)XkbSA_NumActions)
            (*copyActionArgs[action->type])(dpy,xkb,action,buf,&sz);
        else CopyOtherArgs(dpy,xkb,action,buf,&sz);
        TryCopyStr(buf,")",&sz);
    }
    tmp= tbGetBuffer(strlen(buf)+1);
    if (tmp!=NULL)
        strcpy(tmp,buf);
    return tmp;
}
Example #2
0
void to_int()
{
    int i;
    for (i = strlen(input); i > 0; i--) {
        ans[i-1] = input[strlen(input)-i] - '0';
    }
}
Example #3
0
/***********************************************************
* Function:
* Description:
* Input:
* Input:
* Output:
* Return:
* Others:
***********************************************************/
void Disp_Idle( void )
{
    char	buf[20];
    float	angle;

    lcd_fill( 0 );

    sprintf( buf, "20%02d/%02d/%02d",
             YEAR( mytime_now ),
             MONTH( mytime_now ),
             DAY( mytime_now ) );

    lcd_text12( 0, 10, (char*)buf, strlen( buf ), LCD_MODE_SET );

    sprintf( buf, "%02d:%02d:%02d",
             HOUR( mytime_now ),
             MINUTE( mytime_now ),
             SEC( mytime_now ) );
    lcd_text12( 0, 20, (char*)buf, strlen( buf ), LCD_MODE_SET );

    sprintf( buf, "%03d", gps_speed );

    angle = gps_cog * 2.0 * 3.14 / 360.0;

    lcd_text12( 90, 12, (char*)buf, strlen( buf ), LCD_MODE_SET );

    lcd_drawline( 106, 16, 106 + cos( angle ), 16 + sin( angle ), LCD_MODE_SET );

    lcd_bitmap( 0, 3, &BMP_gsm_g, LCD_MODE_SET );
    lcd_bitmap( 8, 3, &BMP_gsm_3, LCD_MODE_SET );
    GPSGPRS_Status( );
    lcd_update_all( );
}
Example #4
0
static void G_Players_f (const Player &player)
{
    int count = 0;
    char smallBuf[64];
    char largeBuf[1280];

    /* print information */
    largeBuf[0] = 0;

    Player *p = nullptr;
    while ((p = G_PlayerGetNextActiveHuman(p))) {
        Com_sprintf(smallBuf, sizeof(smallBuf), "(%i) Team %i %s status: %s\n", p->getNum(),
                    p->getTeam(), p->pers.netname, (p->roundDone ? "waiting" : "playing"));

        /* can't print all of them in one packet */
        if (strlen(smallBuf) + strlen(largeBuf) > sizeof(largeBuf) - 100) {
            Q_strcat(largeBuf, "...\n", sizeof(largeBuf));
            break;
        }
        Q_strcat(largeBuf, smallBuf, sizeof(largeBuf));
        count++;
    }

    G_ClientPrintf(player, PRINT_CONSOLE, "%s\n%i players\n", largeBuf, count);
}
Example #5
0
int authenticateUser() {
    char buf[MAX_LEN];

    if(createUserFlag) {
        sprintf(buf, "IAMNEW %s \r\n\r\n", name);
    } else {
        sprintf(buf, "IAM %s \r\n\r\n", name);
    }

    Send(clientfd, buf, strlen(buf), 0);
    Recv(clientfd, buf, MAX_LEN, 0);

    if(strncmp(buf, "HINEW ", 6) == 0 || strncmp(buf, "AUTH ", 5) == 0) {
        if(strcmp(&buf[strlen(buf)-5], " \r\n\r\n") == 0) {
            return TRUE;
        }
    } else if(strncmp(buf, "ERR 00", 5) == 0) {
        printError("User name taken\n");
        Recv(clientfd, buf, MAX_LEN, 0);
        printLoginLog(auditfd, name, hostname, port, FALSE, "ERR 00 USER NAME TAKEN");
    } else if(strncmp(buf, "ERR 01", 5) == 0) {
        printError("User not available\n");
        Recv(clientfd, buf, MAX_LEN, 0);
        printLoginLog(auditfd, name, hostname, port, FALSE, "ERR 01 USER NOT AVAILABLE");
    }

    return FALSE;
}
Example #6
0
/**
 * Return in @param filename the name of the file we use as unary counter of
 * discrepancies (a compilation failing on the server, but succeeding
 * locally. This function may return NULL in @param filename if the name cannot
 * be determined.
 **/
int dcc_discrepancy_filename(char **filename)
{
    const char *include_server_port = getenv("INCLUDE_SERVER_PORT");
    *filename = NULL;
    if (include_server_port == NULL) {
        return 0;
    } else if (str_endswith(include_server_port_suffix,
                            include_server_port)) {
        /* We're going to make a longer string from include_server_port: one
         * that replaces include_server_port_suffix with discrepancy_suffix. */
        int delta = strlen(discrepancy_suffix) -
                    strlen(include_server_port_suffix);
        assert (delta > 0);
        *filename = malloc(strlen(include_server_port) + 1 + delta);
        if (!*filename) {
            rs_log_error("failed to allocate space for filename");
            return EXIT_OUT_OF_MEMORY;
        }
        strcpy(*filename, include_server_port);
        int slash_pos = strlen(include_server_port)
                        - strlen(include_server_port_suffix);
        /* Because include_server_port_suffix is a suffix of include_server_port
         * we expect to find a '/' at slash_pos in filename. */
        assert((*filename)[slash_pos] == '/');
        (void) strcpy(*filename + slash_pos, discrepancy_suffix);
        return 0;
    } else
        return 0;
}