int ports_initialize(char *ports_string) { char *tok; for(tok = strtok(ports_string, ","); tok; tok = strtok(NULL, ",")) process_tok(tok); return 0; }
/**************************************************************************** process commands from the client ****************************************************************************/ static void do_command(struct client_info *info, char *tok, char *line) { int i; if ((i = process_tok(tok)) >= 0) { commands[i].fn(info); } else if (i == -2) { fprintf(out_hnd, "%s: command abbreviation ambiguous\n", CNV_LANG(tok)); } else { fprintf(out_hnd, "%s: command not found\n", CNV_LANG(tok)); } }
/**************************************************************************** help ****************************************************************************/ void cmd_help(char *dum_in, char *dum_out) { int i=0,j; fstring buf; if (next_token(NULL,buf,NULL)) { if ((i = process_tok(buf)) >= 0) DEBUG(0,("HELP %s:\n\t%s\n\n",commands[i].name,commands[i].description)); } else while (commands[i].description) { for (j=0; commands[i].description && (j<5); j++) { DEBUG(0,("%-15s",commands[i].name)); i++; } DEBUG(0,("\n")); } }
/**************************************************************************** help ****************************************************************************/ static void cmd_help(struct client_info *info) { int i=0,j; fstring buf; if (next_token(NULL,buf,NULL, sizeof(buf))) { if ((i = process_tok(buf)) >= 0) fprintf(out_hnd, "HELP %s:\n\t%s\n\n",commands[i].name,commands[i].description); } else while (commands[i].description) { for (j=0; commands[i].description && (j<5); j++) { fprintf(out_hnd, "%-15s",commands[i].name); i++; } fprintf(out_hnd, "\n"); } }
/**************************************************************************** process commands from the client ****************************************************************************/ static BOOL process(char *base_directory) { extern FILE *dbf; pstring line; char *cmd; char *InBuffer = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN); char *OutBuffer = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN); if ((InBuffer == NULL) || (OutBuffer == NULL)) return(False); bzero(OutBuffer,smb_size); if (!mount_send_login(InBuffer,OutBuffer)) return(False); cmd = cmdstr; if (cmd[0] != '\0') while (cmd[0] != '\0') { char *p; fstring tok; int i; if ((p = strchr(cmd, ';')) == 0) { strncpy(line, cmd, 999); line[1000] = '\0'; cmd += strlen(cmd); } else { if (p - cmd > 999) p = cmd + 999; strncpy(line, cmd, p - cmd); line[p - cmd] = '\0'; cmd = p + 1; } /* input language code to internal one */ CNV_INPUT (line); /* and get the first part of the command */ { char *ptr = line; if (!next_token(&ptr,tok,NULL)) continue; } if ((i = process_tok(tok)) >= 0) commands[i].fn(InBuffer,OutBuffer); else if (i == -2) DEBUG(0,("%s: command abbreviation ambiguous\n",CNV_LANG(tok))); else DEBUG(0,("%s: command not found\n",CNV_LANG(tok))); } else while (!feof(stdin)) { fstring tok; int i; bzero(OutBuffer,smb_size); /* display a prompt */ DEBUG(0,("smb: %s> ", CNV_LANG(cur_dir))); fflush(dbf); #ifdef CLIX line[0] = wait_keyboard(InBuffer); /* this might not be such a good idea... */ if ( line[0] == EOF) break; #else wait_keyboard(InBuffer); #endif /* and get a response */ #ifdef CLIX fgets( &line[1],999, stdin); #else if (!fgets(line,1000,stdin)) break; #endif /* input language code to internal one */ CNV_INPUT (line); /* special case - first char is ! */ if (*line == '!') { system(line + 1); continue; } /* and get the first part of the command */ { char *ptr = line; if (!next_token(&ptr,tok,NULL)) continue; } if ((i = process_tok(tok)) >= 0) commands[i].fn(InBuffer,OutBuffer); else if (i == -2) DEBUG(0,("%s: command abbreviation ambiguous\n",CNV_LANG(tok))); else DEBUG(0,("%s: command not found\n",CNV_LANG(tok))); } cli_send_logout(InBuffer,OutBuffer); return(True); }