# Imakefile for mrtest.
#
-SRCS= mrtest.c tst.c comp.c
+SRCS= mrtest.c
SRCDIR=${SRCTOP}/clients/mrtest
-CODE=${SRCS} Imakefile test_cmds.ct blah.h
-OBJS= mrtest.o test_cmds.o tst.o comp.o
+CODE=${SRCS} Imakefile
+OBJS= mrtest.o
-program(mrtest, ${OBJS},${MR_LIBDEP} ${GDB_LIBDEP}, ${CLIBS} ${SS_LIB},${ETCDIR})
-mk_cmds(test_cmds)
-
-tst.o: mr_err_array.h
-
-mr_err_array.h:
- ${RM} mr_err_array.h
- echo "char * MR_ERR_ARRAY[] = {" > mr_err_array.h
- tr -d , < ../../lib/mr_et.et \
- | awk '$$1=="ec" {printf("\"%s\",\n", $$2)}' >> mr_err_array.h
- echo "};" >> mr_err_array.h
-
-clean::
- ${RM} mr_err_array.h
+program(mrtest, ${OBJS},${MR_LIBDEP} ${GDB_LIBDEP}, ${CLIBS},${ETCDIR})
+++ /dev/null
-/*
- * $Source$
- * $Author$
- * $Header$
- *
- * Copyright (C) 1991 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
- *
- */
-
-#include <ctype.h>
-#include <string.h>
-#include <stdio.h>
-#include <moira.h>
-
-extern char *DataBuf;
-extern char *ErrorBuf;
-extern int count;
-
-CompData (argc, argv, CompStr)
-int argc; /* # of fields outputted by Moira */
-char **argv; /* Array of strings outputted by Moira */
-char **CompStr; /* Pointer to Comparison String -- Data section only */
-/* CompData uses the global variables: */
-/* char *DataBuf; */
-/* char *ErrorBuf; */
-/* int count; */
-{
-int Field = 0; /* Field number being compared */
-int Len, Len2; /* Length of a comparison field */
-int i; /* index for printing */
-
-if (*ErrorBuf == '\0') { /* Don't process if there's a data error already */
-
- for (;(**CompStr) && isspace(**CompStr); (*CompStr)++); /*whitespace*/
- if ((**CompStr != '{') && (**CompStr != '\0'))
- strcpy (ErrorBuf, "Malformed Comparison String");
- else if (**CompStr != '\0') {
- for ((*CompStr)++; ((**CompStr != '}') && (**CompStr != '\0')
- && (Field < argc));) {
- for (;**CompStr && isspace(**CompStr); (*CompStr)++); /* Whitespace */
- if (**CompStr == '*') { /* Wildcard -- field automatically checks */
- (*CompStr)++;}
- else if (**CompStr == '"') { /* Compare a field */
- (*CompStr)++;
- Len = (int)(strchr(*CompStr, '"')) - (int)(*CompStr);
- if (Len < 0) {
- strcpy (ErrorBuf, "Malformed Comparison String");
- break;}
- else if ((strncmp (*CompStr, argv[Field], Len)) ||
- (strlen(argv[Field]) != Len)) { /* Data Error */
- strcpy (ErrorBuf, "Data Error");
- break;}
- *CompStr = (char *)strchr(*CompStr, '"');
- (*CompStr)++;}
- else {
- Len = (int)(strchr(*CompStr, ' ')) - (int)(*CompStr);
- Len2 = (int)(strchr(*CompStr, '}')) - (int)(*CompStr);
- if ((Len < 0) || ((Len2 >= 0) && (Len2 < Len)))
- Len = Len2;
- if (Len < 0)
- strcpy (ErrorBuf, "Malformed Comparison String");
- else {
- if ((strncmp (*CompStr, argv[Field], Len)) ||
- (strlen(argv[Field]) != Len)) { /* Data Error */
- strcpy (ErrorBuf, "Data Error");
- break;}
- *CompStr = (char *)(Len + (int)(*CompStr));}}
- Field++;}
- for (;**CompStr && isspace(**CompStr); (*CompStr)++); /* Whitespace */
- if (*ErrorBuf == '\0') {
- if (**CompStr == '\0')
- strcpy (ErrorBuf, "Malformed Comparison String");
- else if ((**CompStr != '}') || (Field < argc))
- strcpy (ErrorBuf, "Data Error");}
- (*CompStr)++;
- }
- if (!strcmp(ErrorBuf, "Data Error")) strcat (DataBuf, "*****");
-}
-else {
- strcat (DataBuf, " ");}
-
-if (strcmp(ErrorBuf, "Data Error")) strcat (DataBuf, " ");
-
-/* Write Query output to data buffer */
-for (i = 0; i < argc; i++) {
- if (i != 0) strcat (DataBuf, ", ");
- strcat (DataBuf, argv[i]);
-}
-strcat (DataBuf, "\n");
-count++;
-return(MR_CONT);
-}
-
-
-
-
#include <ctype.h>
#include <string.h>
#include <moira.h>
-#include <ss/ss.h>
+#include <com_err.h>
-int ss;
int recursion = 0;
-extern ss_request_table moira_test;
+extern int errno;
extern int sending_version_no;
-int count;
+int count, quit=0;
+char *whoami;
+
+#define MAXARGS 20
main(argc, argv)
int argc;
char **argv;
{
int status;
- char *whoami;
+ char cmdbuf[BUFSIZ];
whoami = argv[0];
- init_ss_err_tbl();
initialize_sms_error_table();
initialize_krb_error_table();
- ss = ss_create_invocation("moira", "2.0", (char *)NULL,
- &moira_test, &status);
- if (status != 0) {
- com_err(whoami, status, "Unable to create invocation");
- exit(1);
+ while(!quit) {
+ printf("moira: ");
+ fflush(stdout);
+ if(!fgets(cmdbuf,BUFSIZ,stdin)) break;
+ execute_line(cmdbuf);
}
- if (argc > 1) {
- argv++;
- ss_execute_command(ss, argv);
+ mr_disconnect();
+ exit(0);
+}
+
+execute_line(cmdbuf)
+ char *cmdbuf;
+{
+ int argc;
+ char *argv[MAXARGS];
+
+ argc=parse(cmdbuf, argv);
+ if(argc==0) return;
+ if(!strcmp(argv[0],"noop"))
+ test_noop();
+ else if(!strcmp(argv[0],"connect") || !strcmp(argv[0],"c"))
+ test_connect(argc, argv);
+ else if(!strcmp(argv[0],"disconnect") || !strcmp(argv[0],"d"))
+ test_disconnect();
+ else if(!strcmp(argv[0],"host"))
+ test_host();
+ else if(!strcmp(argv[0],"new") || !strcmp(argv[0],"2"))
+ test_new();
+ else if(!strcmp(argv[0],"old") || !strcmp(argv[0],"1"))
+ test_old();
+ else if(!strcmp(argv[0],"motd"))
+ test_motd();
+ else if(!strcmp(argv[0],"query") || !strcmp(argv[0],"qy"))
+ test_query(argc, argv);
+ else if(!strcmp(argv[0],"auth") || !strcmp(argv[0],"a"))
+ test_auth(argc, argv);
+ else if(!strcmp(argv[0],"access"))
+ test_access(argc, argv);
+ else if(!strcmp(argv[0],"dcm"))
+ test_dcm();
+ else if(!strcmp(argv[0],"script") || !strcmp(argv[0],"s"))
+ test_script(argc, argv);
+ else if(!strcmp(argv[0],"list_requests") ||
+ !strcmp(argv[0],"lr") || !strcmp(argv[0],"?"))
+ test_list_requests();
+ else if(!strcmp(argv[0],"quit") || !strcmp(argv[0],"Q"))
+ quit=1;
+ else fprintf(stderr, "moira: Unknown request \"%s\"."
+ "Type \"?\" for a request list.\n", argv[0]);
+}
+
+int
+parse(buf, argv)
+ char *buf, *argv[MAXARGS];
+{
+ char *p;
+ int argc, num;
+
+ for(p=buf, argc=0, argv[0]=buf; *p && *p!='\n'; p++) {
+ if(*p=='"') {
+ char *d=p++;
+ /* skip to close-quote, copying back over open-quote */
+ while(*p!='"') {
+ if(!*p || *p=='\n') {
+ fprintf(stderr, "moira: Unbalanced quotes in command line\n");
+ return 0;
}
- ss_listen(ss, &status);
- if (status != 0) {
- com_err(whoami, status, 0);
- exit(1);
+ if(*p=='\\') {
+ if(*++p!='"' && (*p<'0' || *p>'9')) {
+ fprintf(stderr, "moira: Bad use of \\\n");
+ return 0;
+ } else if (*p!='"') {
+ num=(*p-'0')*64 + (*++p-'0')*8 + (*++p-'0');
+ *p=num;
+ }
}
- exit(0);
+ *d++=*p++;
+ }
+ if(p==d+1) {*d='\0'; p++;}
+ else while(p>=d) *p--=' ';
+ }
+ if(*p==' ' || *p=='\t') {
+ /* skip whitespace */
+ for(*p++='\0'; *p==' ' || *p=='\t'; p++);
+ if(*p && *p!='\n') argv[++argc]=p--;
+ }
+ }
+ if(*p=='\n') *p='\0';
+ return argc+1;
}
test_noop()
{
int status = mr_noop();
- if (status) ss_perror(ss, status, "");
+ if (status) com_err("moira (noop)", status, "");
}
test_new()
server = argv[1];
}
status = mr_connect(server);
- if (status) ss_perror(ss, status, "");
+ if (status) com_err("moira (connect)", status, "");
}
test_disconnect()
{
int status = mr_disconnect();
- if (status) ss_perror(ss, status, "");
+ if (status) com_err("moira (disconnect)", status, "");
}
test_host()
memset(host, 0, sizeof(host));
if (status = mr_host(host, sizeof(host) - 1))
- ss_perror(ss, status, "");
+ com_err("moira (host)", status, "");
else
printf("You are connected to host %s\n", host);
}
-test_auth()
+test_auth(argc, argv)
+int argc;
+char *argv[];
{
int status;
status = mr_auth("mrtest");
- if (status) ss_perror(ss, status, "");
+ if (status) com_err("moira (auth)", status, "");
}
test_script(argc, argv)
int status, oldstdout, oldstderr;
if (recursion > 8) {
- ss_perror(ss, 0, "too many levels deep in script files\n");
+ com_err("moira (script)", 0, "too many levels deep in script files\n");
return;
}
if (argc < 2) {
- ss_perror(ss, 0, "Usage: script input_file [ output_file ]");
+ com_err("moira (script)", 0, "Usage: script input_file [ output_file ]");
return;
}
inp = fopen(argv[1], "r");
if (inp == NULL) {
sprintf(input, "Cannot open input file %s", argv[1]);
- ss_perror(ss, 0, input);
+ com_err("moira (script)", 0, input);
return;
}
dup2(oldstdout, 1);
argc = 2;
sprintf(input, "Unable to redirect output to %s\n", argv[2]);
- ss_perror(ss, errno, input);
+ com_err("moira (script)", errno, input);
} else {
fflush(stderr);
oldstderr = dup(2);
continue;
}
printf("Executing: %s\n", input);
- ss_execute_line(ss, input, &status);
- if (status == SS_ET_COMMAND_NOT_FOUND) {
- printf("Bad command: %s\n", input);
- }
+ execute_line(input);
}
recursion--;
}
}
-char *concat(str1, str2)
- char *str1, *str2;
-{
- char *rtn;
- extern char *malloc();
-
- if (!str1) {
- int len = strlen(str2) + 1 ;
- rtn = malloc(len);
- memcpy(rtn, str2, len);
- } else {
- int len1 = strlen(str1);
- int len2 = strlen(str2) + 1;
- rtn = malloc(len1+len2);
- memcpy(rtn, str1, len1);
- memcpy(rtn+len1, str2, len2);
- }
- return rtn;
-}
-
-
-
print_reply(argc, argv)
int argc;
char **argv;
{
int status;
if (argc < 2) {
- ss_perror(ss, 0, "Usage: query handle [ args ... ]");
+ com_err("moira (query)", 0, "Usage: query handle [ args ... ]");
return;
}
count = 0;
status = mr_query(argv[1], argc-2, argv+2, print_reply, (char *)NULL);
printf("%d tuple%s\n", count, ((count == 1) ? "" : "s"));
- if (status) ss_perror(ss, status, "");
+ if (status) com_err("moira (query)", status, "");
}
test_access(argc, argv)
{
int status;
if (argc < 2) {
- ss_perror(ss, 0, "Usage: access handle [ args ... ]");
+ com_err("moira (access)", 0, "Usage: access handle [ args ... ]");
return;
}
status = mr_access(argv[1], argc-2, argv+2);
- if (status) ss_perror(ss, status, "");
+ if (status) com_err("moira (access)", status, "");
}
int status;
if (status = mr_do_update())
- ss_perror(ss, status, " while triggering dcm");
+ com_err("moira (dcm)", status, " while triggering dcm");
}
char *motd;
if (status = mr_motd(&motd))
- ss_perror(ss, status, " while getting motd");
+ com_err("moira (motd)", status, " while getting motd");
if (motd)
printf("%s\n", motd);
else
printf("No message of the day.\n");
}
+
+test_list_requests()
+{
+ printf("Available moira requests:\n");
+ printf("\n");
+ printf("noop\t\t\tAsk Moira to do nothing\n");
+ printf("connect, c\t\tConnect to Moira server\n");
+ printf("disconnect, d\t\tDisconnect from server\n");
+ printf("host\t\t\tIdentify the server host\n");
+ printf("new, 2\t\t\tUse new protocol\n");
+ printf("old, 1\t\t\tUse old protocol\n");
+ printf("motd, m\t\t\tGet the Message of the Day\n");
+ printf("query, qy\t\tMake a query.\n");
+ printf("auth, a\t\t\tAuthenticate to Moira.\n");
+ printf("access\t\t\tCheck access to a Moira query.\n");
+ printf("dcm\t\t\tTrigger the DCM\n");
+ printf("script, s\t\tRead commands from a script.\n");
+ printf("list_requests, lr, ?\tList available commands.\n");
+ printf("quit, Q\t\t\tLeave the subsystem.\n");
+}
+++ /dev/null
-# $Header$
-#
-# Copyright (C) 1991 by the Massachusetts Institute of Technology
-# For copying and distribution information, please see the file
-# <mit-copyright.h>.
-
-
- command_table moira_test;
-
- request test_noop, "Ask Moira to do nothing",
- noop;
-
- request test_connect, "Connect to Moira server",
- connect, c;
-
- request test_disconnect, "Disconnect from server",
- disconnect, d;
-
- request test_host, "Identify the server host",
- host;
-
- request test_new, "Use new protocol",
- new, 2;
-
- request test_old, "Use old protocol",
- old, 1;
-
- request test_motd, "Get the Message of the Day",
- motd, m;
-
- request test_query, "Make a query.",
- query, qy;
-
- request test_auth, "Authenticate to Moira.",
- auth, a;
-
- request test_access, "Check access to a Moira query.",
- access;
-
- request test_dcm, "Trigger the DCM",
- dcm;
-
- request test_script, "Read commands from a script.",
- script, s;
-
- request test_test, "Read commands from a test-file.",
- test, t;
-
- request test_query_compare,
- "[Internal use only:] query and compare data.",
- _compare_query;
-
- request ss_self_identify, "Identify the subsystem.",
- ".",
- (dont_list, dont_summarize);
-
- request ss_list_requests, "List available commands.",
- list_requests, lr, "?";
-
- request ss_quit, "Leave the subsystem.",
- quit, Q;
-
- end;
-
+++ /dev/null
-/*
- * $Source$
- * $Author$
- * $Header$
- *
- * Copyright (C) 1991 by the Massachusetts Institute of Technology
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
- *
- */
-
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/file.h>
-#include <ctype.h>
-#include <string.h>
-#include <moira.h>
-#include <ss/ss.h>
-#include "mr_err_array.h"
-
-extern ss_execute_line();
-extern print_reply();
-extern CompData();
-extern int ss;
-extern int errno;
-extern int count;
-extern int recursion;
-
-char *DataBuf;
-char *ErrorBuf;
-
-test_test (argc, argv)
-int argc;
-char *argv[];
-{
- FILE *inp, *outp;
- char *cp;
- int LineNum;
- int status;
- int NumArgs;
- char *ValArgs[50];
- char lastcmd[BUFSIZ], input[BUFSIZ], cmd[BUFSIZ];
-
- DataBuf = (char *)malloc (2222);
- ErrorBuf = (char *)malloc (30);
-
- if (recursion > 8) {
- ss_perror(ss, 0, "too many levels deep in script/test files\n");
- return;
- }
-
- if (argc < 2) {
- ss_perror(ss, 0, "Usage: test input_file [ output_file ]");
- return;
- }
-
- inp = fopen(argv[1], "r");
- if (inp == NULL) {
- sprintf(cmd, "Cannot open input file %s", argv[1]);
- ss_perror(ss, 0, cmd);
- return;
- }
-
- if (argc == 3) {
- outp = fopen(argv[2], "a");
- if (!outp) {
- sprintf(cmd, "Unable to open output for %s\n", argv[2]);
- ss_perror(ss, errno, cmd);
- return;}}
- else outp = stdout;
-
- *lastcmd = '\0';
-
- recursion++;
-
- for(LineNum = 0;;LineNum++) {
- *DataBuf = '\0';
- *ErrorBuf = '\0';
- if (fgets(input, BUFSIZ, inp) == NULL) {
- if (lastcmd[0] != '\0') {
- strcpy (input, lastcmd);
- lastcmd[0] = '\0';}
- else break;}
- if ((cp = strchr(input, '\n')) != (char *)NULL)
- *cp = 0;
- if (input[0] == 0) continue;
-
- if (input[0] == '%') {
- for (cp = &input[1]; *cp && isspace(*cp); cp++);
- strcat(DataBuf, "Comment: ");
- strcat(DataBuf, cp);
- strcat(DataBuf, "\n");
- continue;
- }
-
- if (input[0] == '>') { /* Load in a Comparison String */
- if (lastcmd[0] == '\0') {
- fprintf(outp,
- "\nERROR IN LINE %d: Comparison String Without Comparable Command\n",
- LineNum);
- fprintf(outp, "%s\n", input);
- *DataBuf = '\0';
- continue;}
- else { /* Parse and Execute command with compare */
- sprintf (cmd, "COMPARE_%s", lastcmd);
- memset((char *)ValArgs, 0, sizeof(ValArgs));
- Partial_parse_string(0, cmd, &NumArgs, ValArgs);
- ValArgs[NumArgs] = (char *)malloc(sizeof(char) * (1+strlen(input)));
- strcpy(ValArgs[NumArgs], input);
- status = ss_execute_command(ss, ValArgs);
- lastcmd[0] = '\0';
-
-/* Dump errors and data if necessary */
- if (!strcmp(ErrorBuf, "Malformed Comparison String0")) {
- fprintf(outp, "\nERROR IN LINE %d: %s\n", LineNum, ErrorBuf);
- fprintf(outp, "%s\n", input);
- continue;}
- else if (*ErrorBuf) { /* Data Error */
- fprintf(outp, "\nERROR IN LINE %d: %s\n", LineNum, ErrorBuf);
- fprintf(outp, "%s\n", DataBuf);
- continue;}
- else continue; /* Command Checks */
- }}
-
-/* It wasn't a Comparison line, so clear the stack */
- if (lastcmd[0] != '\0') { /* Run an old command w/o a comparison string */
- ss_execute_line(ss, lastcmd, &status);
- if (status == SS_ET_COMMAND_NOT_FOUND)
- printf("Bad command: %s\n", input);
- *lastcmd = '\0';}
-
-/* Push command on the stack if it's comparable (currently only queries are) */
- if (!(strncasecmp (input, "qy ", 3) && strncasecmp (input, "query ", 6))) {
- /* Delay this command in case there's a comparison line following it */
- strcpy (lastcmd, input);
- continue;}
-
-/* Non-comparible command; execute immediately */
- ss_execute_line(ss, input, &status);
- if (status == SS_ET_COMMAND_NOT_FOUND) {
- printf("Bad command: %s\n", input);
- }
- }
-
- recursion--;
-
- fclose(inp);
- if (argc > 2)
- close(outp);
-}
-
-/**********************************/
-
-test_query_compare(argc, argv)
- int argc;
- char **argv;
-{ /* argv = "COMPARE_qy" + args to query + compstring */
- int Qstatus = 0; /* Status returned from the query */
- char *CompTo[5];
- int NumWordsComp=0, i;
-
- if (argc < 2) {
- ss_perror(ss, 0, "Usage: query handle [ args ... ]");
- return;
- }
-/* Execute query with a comparison string */
- count = 0;
-
- /* Parse comp string into '>', char, ErrMsg, NumEntries, and Data */
- memset((char *)CompTo, 0, sizeof(CompTo));
- Partial_parse_string (4, argv[argc-1], &NumWordsComp, CompTo);
- if (NumWordsComp < 3) { /* Too few args in comparison string */
- strcpy(ErrorBuf, "Malformed Comparison String1");}
- else {
-
- for (i=0;i<argc;i++) {
- printf("argv[%d] = %s\n", i, argv[i]);}
- printf("CompTo[3] = %s\n\n", CompTo[3]);
-
-
- Qstatus = mr_query(argv[1], argc-3, argv+2, CompData,
- (char *)(&CompTo[3]));
-
-/* Check the number of tuples returned */
- if (*CompTo[2] == '<') {
- if (isdigit(*(CompTo[2] + 1))) {
- if (atoi(CompTo[2] + 1) <= count)
- strcat(ErrorBuf, "\nToo many tuples returned");}
- else if (*ErrorBuf == '\0')
- strcpy(ErrorBuf, "Malformed Comparison String2");}
- else if (*CompTo[2] == '>') {
- if (isdigit(*(CompTo[2] + 1))) {
- if (atoi(CompTo[2] + 1) >= count)
- strcat(ErrorBuf, "\nToo few tuples returned");}
- else if (*ErrorBuf == '\0')
- strcpy(ErrorBuf, "Malformed Comparison String3");}
- else if (isdigit(*(CompTo[2]))) {
- if (atoi(CompTo[2]) != count)
- strcat(ErrorBuf, "\nWrong number tuples returned");}
- else if (strcmp(CompTo[2], "*"))
- if (*ErrorBuf == '\0')
- strcpy(ErrorBuf, "Malformed Comparison String4");
-
- /* Check return status */
- if (!Comp_mr_err_table(Qstatus, CompTo[1]))
- {
- strcat(ErrorBuf, "\nRet Status Error, returns: ");
- if (Qstatus)
- strcat(ErrorBuf, MR_ERR_ARRAY[Qstatus - ERROR_TABLE_BASE_sms]);
- else
- strcat(ErrorBuf, "SUCCESS");}
-
- }}
-
-/********************************************/
-
-int Comp_mr_err_table (ErrNum, ErrName)
-int ErrNum;
-char *ErrName;
-
-/* Returns 1 if ErrNum = the string in ErrName in MR_ERR_ARRAY, else 0 */
-
-{
-if (!ErrNum && ((!strcasecmp(ErrName, "SUCCESS"))
- || (!strcasecmp(ErrName, "S"))))
- return(1);
-else if (!ErrNum) return (0);
-else if (ErrNum >= ERROR_TABLE_BASE_sms)
- return (!strcmp (MR_ERR_ARRAY[ErrNum - ERROR_TABLE_BASE_sms], ErrName));
-else return (0);
-}
-
-/********************************************/
-
-int NumWords (Str)
-char *Str;
-{
-int Count;
-int CharIndex;
-
-for (CharIndex = 0, Count = 0;*(Str + CharIndex);) {
- if (isspace(*(Str + CharIndex)))
- for (;isspace(*(Str + CharIndex));CharIndex++);
- else if (*(Str + CharIndex) && !isspace(*(Str + CharIndex)))
- for (Count++;(*(Str + CharIndex) && !isspace(*(Str + CharIndex)));
- CharIndex++);
-}
-return(Count);
-}
-
-/**********************/
-
-/*
- * Partial_parse_string(MaxWords, Str, argc_ptr, argv_ptr)
- *
- * Function:
- * Parses line, dividing at whitespace, into tokens, returns
- * the "argc" and "argv" values, up to MaxWords-1 tokens. Remaining
- * tokens after MaxWords-1 are all returned as one set in the final
- * slot of "argv". If MaxWords = 0, the number of tokens is not limited.
- * Arguments:
- * MaxWords (int)
- * Maximum number of tokens/strings to return
- * Str (char *)
- * Pointer to text string to be parsed.
- * argc_ptr (int *)
- * Where to put the "argc" (number of tokens) value.
- * argv_ptr (char *[])
- * Series of pointers to parsed tokens
- */
-
-Partial_parse_string (MaxWords, Str, argc_ptr, argv_ptr)
-int MaxWords;
-char *Str;
-int *argc_ptr;
-char *argv_ptr[];
-
-{
-char Buf[BUFSIZ];
-int NumTokens;
-int CharIndex;
-int i;
-
-for (CharIndex = 0, NumTokens = 0;*(Str + CharIndex)
- && ((NumTokens < MaxWords-1) || !MaxWords);) {
- if (isspace(*(Str + CharIndex)))
- for (;isspace(*(Str + CharIndex));CharIndex++);
- else if (*(Str + CharIndex) && !isspace(*(Str + CharIndex)))
- for (NumTokens++, i=0;(*(Str + CharIndex) && !isspace(*(Str + CharIndex)));
- CharIndex++, i++) Buf[i] = *(Str + CharIndex);
- Buf[i] = '\0';
- argv_ptr[NumTokens-1] = (char *)malloc(sizeof(char) * (strlen(Buf) + 1));
- strcpy(argv_ptr[NumTokens-1], Buf);
-}
-*argc_ptr = NumTokens;
-if (NumTokens = MaxWords) {
- argv_ptr[NumTokens-1]=
- (char *) malloc(sizeof(char) * (1 + strlen(Str + CharIndex)));
- strcpy (argv_ptr[NumTokens-1], (Str + CharIndex));}
-
-}
-