void make_cmd(t_env *e, int cs, char *line) { char *arg; arg = less_cmd(line); if (ft_verify_word(line, "/nick") == 0) check_name(e, cs, arg); else if (ft_verify_word(line, "/join") == 0) make_join(e, cs, arg); else if (ft_strcmp(line, "/leave") == 0) make_leave(e, cs, arg); else if (ft_strcmp(line, "/who") == 0) make_who(e, cs, arg); else if (ft_verify_word(line, "/msg") == 0) make_msg(e, cs, arg); else send(cs, "Wrong command.\0", 15, 0); }
/* Process a single .desc line. */ static int process_line( SymbolTable *st, const char *text ) { char line[1024]; #ifdef DEBUG printf( "read: %s\n", text ); #endif /*DEBUG*/ /* We destroy line during the parse. */ im_strncpy( line, text, 1024 ); if( im_isprefix( "#LRJOIN ", line ) || im_isprefix( "#TBJOIN ", line ) ) { /* Yes: magic join command. Break into tokens. Format is eg. #LRJOIN <left> <right> <out> <x> <y> [<mwidth>] */ char *item[MAX_ITEMS]; int nitems; JoinType type; JoinNode *arg1, *arg2, *join; int dx, dy, mwidth; if( (nitems = break_items( line, item )) < 0 ) return( -1 ); if( nitems != 5 && nitems != 6 ) { im_error( "global_balance", _( "bad number of args in join line" ) ); return( -1 ); } if( !(arg1 = add_node( st, item[0] )) || !(arg2 = add_node( st, item[1] )) || !(join = add_node( st, item[2] )) ) return( -1 ); dx = atoi( item[3] ); dy = atoi( item[4] ); if( nitems == 6 ) mwidth = atoi( item[5] ); else mwidth = -1; if( im_isprefix( "#LRJOIN ", line ) ) type = JOIN_LR; else type = JOIN_TB; if( make_join( st, type, arg1, arg2, join, 1.0, 0.0, dx, dy, mwidth ) ) return( -1 ); } else if( im_isprefix( "#LRROTSCALE ", line ) || im_isprefix( "#TBROTSCALE ", line ) ) { /* Rot + scale. Format is eg. #LRROTSCALE <left> <right> <out> \ <a> <b> <x> <y> [<mwidth>] */ char *item[MAX_ITEMS]; int nitems; JoinType type; JoinNode *arg1, *arg2, *join; double a, b, dx, dy; int mwidth; if( (nitems = break_items( line, item )) < 0 ) return( -1 ); if( nitems != 7 && nitems != 8 ) { im_error( "global_balance", _( "bad number of args in join1 line" ) ); return( -1 ); } if( !(arg1 = add_node( st, item[0] )) || !(arg2 = add_node( st, item[1] )) || !(join = add_node( st, item[2] )) ) return( -1 ); a = g_ascii_strtod( item[3], NULL ); b = g_ascii_strtod( item[4], NULL ); dx = g_ascii_strtod( item[5], NULL ); dy = g_ascii_strtod( item[6], NULL ); if( nitems == 8 ) mwidth = atoi( item[7] ); else mwidth = -1; if( im_isprefix( "#LRROTSCALE ", line ) ) type = JOIN_LRROTSCALE; else type = JOIN_TBROTSCALE; if( make_join( st, type, arg1, arg2, join, a, b, dx, dy, mwidth ) ) return( -1 ); } else if( im_isprefix( "copy ", line ) ) { /* im_copy() call ... make a JOIN_CP node. */ char *item[MAX_ITEMS]; int nitems; JoinNode *before, *after; if( (nitems = break_items( line, item )) < 0 ) return( -1 ); if( nitems != 2 ) { im_error( "global_balance", _( "bad number of args in copy line" ) ); return( -1 ); } if( !(before = add_node( st, item[0] )) || !(after = add_node( st, item[1] )) || make_copy( st, before, after ) ) return( -1 ); } return( 0 ); }