int main() { volatile int i; check_vect (); for (i = 0; i < N; i++) src[i] = i << 3; array_shift (); for (i = 0; i < N; i++) if (dst[i] != i) abort (); return 0; }
int main (void) { char file_in[FILENAME_SIZE], file_out[FILENAME_SIZE]; FILE *fpin, *fpout; char LR; int s, e; int file_size; int i; unsigned char *pt_uc; scanf("%s%s", file_in, file_out); getchar(); scanf("%c", &LR); scanf("%d%d", &s, &e); file_size = get_file_size(file_in, "rb"); pt_uc = (unsigned char *)malloc(file_size); assert(pt_uc != NULL); fpin = fopen(file_in, "rb"); assert(fpin != NULL); fread(pt_uc, sizeof(unsigned char), file_size, fpin); fclose(fpin); array_shift(pt_uc, file_size, LR, s); array_all_unit_xor(ptuc, file_size, e); fpout = fopen(file_out, "wb"); assert(fpout != NULL); fwrite(pt_uc, sizeof(unsigned char), file_size, fpout); fclose(fpout); free(pt_uc); return 0; }
int irc_parse_line(session_t *s, const char *l) { static GString *strbuf = NULL; irc_private_t *j = s->priv; int i, c=0, ecode, n_params; char *p, *cmd, *colon2, **args = NULL, **pfxcmd = NULL; gchar *buf; int len; if (G_UNLIKELY(!strbuf)) strbuf = g_string_new(l); else g_string_assign(strbuf, l); irc_convert_in(j, strbuf); buf = strbuf->str; len = strbuf->len; query_emit(NULL, "irc-parse-line", &s->uid, &buf); p=buf; if(!p) return -1; /* Each IRC message may consist of up to three main parts: the prefix (optional), the command, and the command parameters (of which there may be up to 15). The prefix, command, and all parameters are separated by one (or more) ASCII space character(s) (0x20). The presence of a prefix is indicated with a single leading ASCII colon character (':', 0x3b), which must be the first character of the message itself. There must be no gap (whitespace) between the colon and the prefix. */ /* GiM: In fact this is probably not needed, but just in case... */ for (i=0; i<len; i++) if (buf[i]=='\n' || buf[i]=='\r') buf[i]='\0'; if ((colon2=xstrstr(p, " :"))) *colon2 = '\0'; args = array_make(OMITCOLON(p), " ", 0, 1, 0); if (colon2) { *colon2 = ' '; array_add(&args, xstrdup(colon2+2)); } #define prefix pfxcmd[0] #define pfx_nick pfxcmd[1] #define pfx_ihost pfxcmd[2] #define cmdname pfxcmd[3] /* prefix is optional... */ if (':' != *buf) { array_add(&pfxcmd, g_strdup("")); // prefix array_add(&pfxcmd, g_strdup("")); // pfx_nick array_add(&pfxcmd, g_strdup("")); // pfx_ihost } else { array_add(&pfxcmd, array_shift(&args)); // prefix p = xstrchr(pfxcmd[0], '!'); array_add(&pfxcmd, p ? g_strndup(pfxcmd[0], p-pfxcmd[0]) : g_strdup("")); // pfx_nick array_add(&pfxcmd, p ? g_strdup(p+1) : g_strdup("")); // pfx_ihost } cmd = array_shift(&args); array_add(&pfxcmd, cmd); // cmdname /* debug only nasty hack ;> */ #ifdef GDEBUG /* mg: well, it's not the exact data sent, but color is needed indeed */ i=0; if (*pfxcmd[0]) debug_iorecv("[%s]", pfxcmd[0]); debug_iorecv("[%s]", cmd); while (args[i] != NULL) debug_iorecv("[%s]",args[i++]); debug_iorecv("\n"); #endif n_params = g_strv_length(args); if (xstrlen(cmd) > 1) { if(!gatoi(cmd, &ecode)) { /* for scripts */ char *emitname = saprintf("irc-protocol-numeric %s", cmd); if ((query_emit(NULL, "irc-protocol-numeric", &s->uid, &ecode, &args) == -1) || (query_emit(NULL, emitname, &s->uid, &args) == -1)) { xfree(emitname); g_strfreev(pfxcmd); g_strfreev(args); return -1; } xfree(emitname); c=0; while(irccommands[c].type != -1) { if (irccommands[c].type == 1 && irccommands[c].num == ecode) { if (irccommands[c].min_params > n_params) { debug_error("[irc] parse_line() Not enough parameters! cmd=%s, n=%d, min=%d\n", cmd, n_params, irccommands[c].min_params); } else /* I'm sending c not ecode!!!! */ if ((*(irccommands[c].handler))(s, j, c, pfxcmd, args) == -1 ) { debug_error("[irc] parse_line() error while executing handler!\n"); } /* GiM: XXX I don't expect more, * then one handler on list... */ break; } c++; } #ifdef GDEBUG if (irccommands[c].type == -1) { debug("trying default handler\n"); if ((*(irccommands[0].handler))(s, j, 0, pfxcmd, args) == -1 ) { debug("[irc] parse_line() error while executing handler!\n"); } } #endif } else { c=0; while(irccommands[c].type != -1) { if (irccommands[c].type == 0 && !xstrcmp(irccommands[c].comm, cmd)) { if (irccommands[c].min_params > n_params) { debug_error("[irc] parse_line() Not enough parameters! cmd=%s, n=%d, min=%d\n", cmd, n_params, irccommands[c].min_params); } else /* dj: instead of ecode, c; */ if ((*(irccommands[c].handler))(s, j, c, pfxcmd, args) == -1 ) { debug_error("[irc] parse_line() error while executing handler!\n"); } break; } c++; } } } g_strfreev(pfxcmd); g_strfreev(args); return 0; }