Main Page   Compound List   File List   Compound Members   File Members  

zephyr-core.vtc

Go to the documentation of this file.
00001 /* -*- C -*- */
00088 Tzgram ?:= new_assoc();
00089 /*?
00090 struct Tzgram
00091 {
00092   personal;
00093   opcode;
00094   class;
00095   instance;
00096   sender;
00097   fromhost;
00098   ztime;
00099   auth;
00100   fields;
00101   numfields;
00102 };
00103 ?*/
00104 
00111 func new_zgram() [zgram]
00112 {
00113     zgram = alloc(10, Tzgram);
00114     zgram->personal = 0;
00115     zgram->opcode = "";
00116     zgram->class = "";
00117     zgram->instance = "";
00118     zgram->sender = "";
00119     zgram->fromhost = "";
00120     zgram->ztime = "";
00121     zgram->auth = "";
00122     zgram->fields = alloc(2); /* usual case */
00123     zgram->numfields = 0;
00124     return zgram;
00125 }
00126 
00134 func zapply(f, z)
00135 {
00136   z->opcode = (*f)(z->opcode);
00137   z->class = (*f)(z->class);
00138   z->instance = (*f)(z->instance);
00139   z->fromhost = (*f)(z->fromhost);
00140   z->sender = (*f)(z->sender);
00141   z->ztime = (*f)(z->ztime);
00142   z->auth = (*f)(z->auth);  
00143 }
00144 
00147 ZEPHYR ?:= alloc(5, Twtype);
00148 ZEPHYR->name = "Zephyr";
00149 
00157 func zephyr_init(world, rmt, login)
00158 {
00159     world->status = "";
00160     world->class_defaults = make_tree(.stricmp);
00161     world->zephyr = new_zgram();
00162 }
00163 ZEPHYR->init = .zephyr_init;
00164 
00170 func zephyr_cleanup(world)
00171 {
00172     if (rmt_win(world->rmt))
00173         del_status(rmt_win(world->rmt), world->status);
00174 }
00175 ZEPHYR->cleanup = .zephyr_cleanup;
00176 
00184 func zephyr_change_window(world, old, new)
00185 {
00186     if (old)
00187         del_status(old, world->status);
00188     add_status(new, world->status);
00189 }
00190 ZEPHYR->change_window = .zephyr_change_window;
00191 
00198 func zephyr_netread(line) [n] {
00199     if (strcmp(line, "mail") == 0)
00200         output("New mail\n", S_HILITE);
00201     else if (strcmp(line, "personal") == 0)
00202         cur_rmt->zephyr->personal = 1;
00203     else if (strcmp(line, "done") == 0)
00204         zephyr_output();
00205     else if (strcmp(line, "opcode: ", 8) == 0)
00206         cur_rmt->zephyr->opcode += (line + 8) + "\n";
00207     else if (strcmp(line, "class: ", 7) == 0)
00208         cur_rmt->zephyr->class += (line + 7) + "\n";
00209     else if (strcmp(line, "instance: ", 10) == 0)
00210         cur_rmt->zephyr->instance += (line + 10) + "\n";
00211     else if (strcmp(line, "sender: ", 8) == 0)
00212         cur_rmt->zephyr->sender += (line + 8) + "\n";
00213     else if (strcmp(line, "fromhost: ", 10) == 0)
00214         cur_rmt->zephyr->fromhost += (line + 10) + "\n";
00215     else if (strcmp(line, "time: ", 6) == 0)
00216         cur_rmt->zephyr->ztime += (line + 6) + "\n";
00217     else if (strcmp(line, "auth: ", 6) == 0)
00218         cur_rmt->zephyr->auth += (line + 6) + "\n";
00219     else if (regexec(zfieldregex, line) != 0) {
00220         n = atoi(regmatch(zfieldregex, 1));
00221         if (n >= cur_rmt->zephyr->numfields) {
00222             cur_rmt->zephyr->numfields = n+1;
00223             cur_rmt->zephyr->fields[n] = "";
00224         }
00225         cur_rmt->zephyr->fields[n] += regmatch(zfieldregex, 2) + "\n";
00226     }
00227     else if (*line)
00228         printf("%s\n", line);
00229 }
00230 ZEPHYR->netread = .zephyr_netread;
00231 
00238 func zephyr_save(w, fp) {
00239     fprintf(fp, "%s(%s);\n", func_name(w->type->add), arglist(w->name));
00240 }
00241 ZEPHYR->save = .zephyr_save;
00242 
00248 func zephyr_list(w) {
00249     printf("%15s %10s\n", w->name, w->type->name);
00250 }
00251 ZEPHYR->list = .zephyr_list;
00252 
00258 func zephyr_print(w) {
00259     printf("Type: %s\n", w->type->name);
00260     printf("Name: %s\n", w->name);
00261 }
00262 ZEPHYR->print = .zephyr_print;
00263 
00264 /* zephyr_outbound goes here */
00265 
00272 func add_zephyr(name) {
00273                 add_world(new_shell(ZEPHYR, name, "exec zwgc -nofork -f $HOME/.zwgc.desc.vt"));
00274 }
00275 ZEPHYR->add = .add_zephyr;
00276 
00277 add_cmd("add_zephyr", 1, .add_zephyr, "/add_zephyr <name>");
00278 

Generated at Mon Aug 13 16:45:52 2001 for dzm-vtc by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001