static void config_input(void) { int choice; char dev_type; char buf[PATH_SIZE]; USHORT idis[9]; UBYTE modes[IDR_MAX_OPTIONS]; char sbuf[80]; clear_mem(idis,sizeof(idis)); idis[vconfg.dev_type] = QCF_ASTERISK; if(!resource_exists(summa_idriver_name)) idis[1] |= QCF_DISABLED; choice = soft_qchoice(idis, "input_device" ); switch (choice) { default: return; case 0: dev_type = 0; strcpy(buf, mouse_idriver_name); break; case 1: dev_type = 1; strcpy(buf, summa_idriver_name); break; case 2: if(vconfg.dev_type == 2) strcpy(buf,vconfg.idr_name); else buf[0] = 0; if(!req_resource_name(buf,"*.idr", stack_string("idr_scroll", sbuf))) { return; } dev_type = 2; break; case 3: if (!get_serial_port()) return; goto REWRITE; } memcpy(modes,vconfg.idr_modes,sizeof(modes)); if(config_idriver(buf, modes, txtcmp(vconfg.idr_name,buf) == 0, (SHORT)vconfg.comm_port) < Success) { return; } vconfg.dev_type = dev_type; memcpy(vconfg.idr_modes,modes,sizeof(modes)); strcpy(vconfg.idr_name, buf); REWRITE: rewrite_config(); cleanup_idriver(); init_input(); }
Errcode pj_open_ddriver(Vdevice **pvd, char *name) /************************************************************************* * Open up a loadable display driver. This is the call that PJ and the * driver torture program use as the first step in establishing * a working graphics screen. This call provides the driver with * more debugging functions than the standard pj_open_vdriver() * call. Requires client to provide aa_syslib and aa_stdiolib. * * There should be a matching pj_close_vdriver() when the client is * finished with the driver. * * Parameters: * Vdevice **pvd; returns pointer to open video device * char *name; name of driver file (or pj_mcga_name for * built in 320x200 MCGA/VGA driver) * Returns: * Success (0) if driver found * negative error code on failure (see errcodes.h) *************************************************************************/ { if (!txtcmp(pj_get_path_name(name), pj_mcga_name)) return(pj_open_mcga_vdriver(pvd)); #ifdef USE_DYNAMIC_VIDEO_DRIVERS return(pj_open_loadable_vdriver(pvd,name)); #else /* USE_DYNAMIC_VIDEO_DRIVERS */ return Err_unimpl; #endif /* USE_DYNAMIC_VIDEO_DRIVERS */ }
Errcode vset_set_pathinfo(int ptype, Vset_path *pathinfo) /* this may be slow but it does the job */ { Errcode err; Vsetfile vsf; char *name; char save_name[PATH_SIZE]; if(((unsigned int)ptype) >= VSET_NUM_PATHS) /* unrecognized type */ return(Success); /* remove "unnamed" names */ name = pj_get_path_name(pathinfo->path); strcpy(save_name,name); *pj_get_path_suffix(name) = 0; if(txtcmp(unnamed_str,name) == 0) *name = 0; else strcpy(name,save_name); err = reopen_tsettings(&vsf); if (err >= Success) { err = xffwriteoset(vsf.xf, pathinfo, path_type_offset(&vsf,ptype), sizeof(Vset_path)); close_vsetfile(&vsf); } strcpy(name,save_name); return(err); }
static Errcode po_ink_set(Popot name) /***************************************************************************** * ErrCode SetInk(char *name) ****************************************************************************/ { extern Option_tool *ink_list; Option_tool *l; if (name.pt == NULL) return(builtin_err = Err_null_ref); l = ink_list; while (l != NULL) { if (txtcmp(name.pt, l->name) == 0) { free_render_cashes(); set_curink(l); set_render_fast(); make_render_cashes(); return(Success); } l = l->next; } return(Err_not_found); }
static Boolean show_driver_info(Names *entry,void *dat) { Errcode err; Vmode_info mi; Mode_entry *mentry; Vdevice *drv = NULL; Boolean is_current; char *more_info; char *soft_info = NULL; (void)dat; if (NULL == (mentry = (Mode_entry *)entry)) /* it's possible for us to */ return FALSE; /* get called with a NULL ptr! */ hide_mp(); is_current = !txtcmp(vconfg.smode.drv_name, mentry->drv_file); if(is_current) drv = vb.vd; else { if((err = pj_open_ddriver(&drv, mentry->drv_file)) < Success) goto error; } if((err = pj_vd_get_mode(drv,mentry->mode,&mi)) < Success) goto error; /* check for softmenu key and retrieve pointer to text */ more_info = pj_vd_get_more_info(drv,mentry->mode); /* replace key with allocated softmenu text. If we have a key. * will set soft_info to NULL if an error */ if( ((soft_info = rex_key_or_text(more_info,&more_info)) != NULL) && (smu_load_name_text(&smu_sm,"vdriver_texts", soft_info, &soft_info) >= Success)) { more_info = soft_info; } soft_continu_box("!%s%s%d%d%d%d%d%d%d", "vdriver_info", more_info, mentry->drv_file, mentry->mode, mi.bits, mi.width.min, mi.width.max, mi.height.min, mi.height.max, mi.store_bytes ); error: smu_free_text(&soft_info); if(!is_current) pj_close_vdriver(&drv); softerr(err,"!%s%d", "driver_info", mentry->drv_file, mentry->mode); show_mp(); return FALSE; /* indicate we don't want exit from menu */ }
Names *text_in_list(char *name, Names *list) /* does case independent search for "name" in list */ { while(list != NULL) { if(txtcmp(list->name, name) == 0) break; list = list->next; } return(list); }
static void see_opt_wild(Button *b) { set_button_disable(b, b->datme == NULL); if(b->datme) { if(!txtcmp(*(char **)(b->group),b->datme)) b->flags |= MB_HILIT; else b->flags &= ~MB_HILIT; ccorner_text(b); } else white_block(b); }
static Errcode default_temp_path(char *buf) /* Put default temp path into buf. This will be X:\PAAT;C:\PAAT in most * cases, (where X: is the startup drive) but just C:\PAAT if current device * is a floppy or C: */ { char device[DEV_NAME_LEN]; Errcode err; if((err = current_device(device)) < Success) return(err); if (!pj_is_fixed(device) || txtcmp(device, "C") == 0) strcpy(buf, "C:\\PAAT;"); else sprintf(buf, "%s:\\PAAT;C:\\PAAT", device); return(Success); }
static Rfile find_named(char *name) /* Return directory entry of a named file if it exists, NULL otherwise. */ { int tf; Temp_file *tpf; for (tf=0; tf<MAX_TEMPS; tf++) { tpf = &glo_tpf[tf]; if (tpf->flags&TF_USED) { if (txtcmp(tpf->name, name) == 0) return(tpf); } } rerr = Err_no_file; return(NULL); }
bool initnetwork(word port) { if (netinitialized) { msg("Networking Error","An attempt was made to initialize the networking module more than once"); } int fromlen=sizeof(testfrom); #ifdef PLATFORM_win32 if (WSAStartup(0x202,&wsaData)) { reportNetError(); WSACleanup(); return false; } #endif netinitialized = true; serverok = inittestserver(port); clientok = inittestclient(port); if (!clientok) serverok = false; if (clientok && serverok) { // Receive initial test packet char buf[10]; long retval = WSAEWOULDBLOCK; dword timeouttime = globalTimer + currentTimerHz * 2; while (retval==WSAEWOULDBLOCK && globalTimer<timeouttime) { checkmsg(); retval = recvfrom(testserversocket,buf,10,0,(struct sockaddr *)&testfrom,&fromlen); if (retval == SOCKET_ERROR || retval == 0 || txtcmp(buf,"test")!=0) { serverok = false; closesocket(testserversocket); } } if (globalTimer>=timeouttime) { serverok = false; closesocket(testserversocket); } } if (serverok) closesocket(testserversocket); if (clientok) closesocket(testclientsocket); return true; }
Errcode pj_open_vdriver(Vdevice **pvd, char *name) /************************************************************************* * Open up a loadable display driver. This is the call that most * display driver clients will use as the first step in establishing * a working graphics screen. Clients wishing to provide the driver * with extra debugging functions use pj_open_ddriver() instead. This * requires the client provide the library aa_syslib. * * There should be a matching pj_close_vdriver() when the client is * finished with the driver. * * Parameters: * Vdevice **pvd; returns pointer to open video device * char *name; name of driver file (or pj_mcga_name for * built in 320x200 MCGA/VGA driver) * Returns: * Success (0) if driver found * negative error code on failure (see errcodes.h) *************************************************************************/ { if (!txtcmp(pj_get_path_name(name), pj_mcga_name)) return(pj_open_mcga_vdriver(pvd)); return(pj__vdr_initload_open(load_driver,pvd,name)); }
static Errcode qfile( char *path_out, /* Initial contents ignored. Returns full path. */ char *dir_in, /* Directory. Updated by routine if user changes it */ char *file_in, /* File name. Updated by routine if user changes it */ char *prompt, /* Line of text to display at top of requestor */ char *ok_text, /* string for the 'ok' button */ int num_wilds, /* number of wildcards */ char **wildcards, /* list of wildcards (<3) First is default read only */ char *wildbuf) /* buffer for wildcard must be at least "WILD_SIZE" long */ { Button *dhanger, *wildb; Errcode err; void *ss = NULL; redisplay_drawer = new_drawer; make_good_dir(dir_in); fq_drawer = dir_in; set_stq_string(&drawer_stringq,dir_in); set_stq_string(&file_stringq,file_in); if(num_wilds <= 0) { if(!wildbuf[0]) wildbuf[0] = 0; } else { if(!wildbuf[0]) strncpy(wildbuf,wildcards[0],WILD_SIZE-1); --wildcards; for(wildb = fmu_sdots_sel.children;wildb != NULL;wildb = wildb->next) { for(;;) { if(num_wilds-- <= 0) { wildb->datme = NULL; break; } ++wildcards; if(!txtcmp(*wildcards,fmu_sdots_sel.datme)) continue; wildb->datme = *wildcards; break; } } } set_stq_string(&wild_stringq,wildbuf); /* if more than 12 buttons hang up higher -2 for '\' and '..' */ if(pj_get_devices(NULL) > (12 - 2)) dhanger = &fmu_topdev_hanger; else dhanger = &fmu_dev_hanger; fmu_sdots_sel.next = dhanger; if((err = alloc_dev_sels(dhanger,&fmu_devsel_320size,4,5,dir_in, new_drawer_with_data, NULL)) < Success) { goto error; } if((err = soft_buttons("fscroll_panel", fmu_smblist, Array_els(fmu_smblist), &ss)) < Success) { goto error; } /* note text put in after buttons are loaded */ fok_sel.datme = ok_text; ftitle_sel.datme = prompt; /* display prompt in move area... */ fscroller.top_name = *fscroller_top_name; init_fscroller(); menu_to_cursor(icb.input_screen,&fileq_menu); err = do_reqloop(icb.input_screen, &fileq_menu, &ffile_sel,NULL,NULL); full_path_name(drawer_stringq.string,file_stringq.string,path_out); *fscroller_top_name = fscroller.top_name; error: smu_free_scatters(&ss); cleanup_dev_sels(dhanger); free_wild_list(&wild_lst); return(softerr(err, NULL)); }
Boolean flipaths_same(Flipath *pa, Flipath *pb) { return( 0 == memcmp(&pa->fid,&pb->fid,sizeof(pa->fid)) && 0 == txtcmp(pa->path,pb->path)); }
static Errcode build_mode_list(Mode_entry **pmlist,Names **pwildlist, Names **pcurrent ) { extern char pj_mcga_name[]; Errcode err; Names mcga_entry; Names *drv_entry; Mode_entry **pmode_entry; Mode_entry *mentry; Vmode_info mode_info; Vdevice *drv = NULL; Boolean is_current = FALSE; USHORT mode; char wstr[32]; char hstr[32]; int mode_count; #ifdef USE_DYNAMIC_VIDEO_DRIVERS build_wild_list(pwildlist, "*.drv", FALSE); #else /* USE_DYNAMIC_VIDEO_DRIVERS */ *pwildlist = NULL; #endif /* USE_DYNAMIC_VIDEO_DRIVERS */ drv_entry = &mcga_entry; mcga_entry.name = pj_mcga_name; mcga_entry.next = *pwildlist; pmode_entry = pmlist; *pcurrent = NULL; while(drv_entry != NULL) { is_current = !txtcmp(vconfg.smode.drv_name, drv_entry->name); if(is_current) { drv = vb.vd; } else if((err = pj_open_ddriver(&drv, drv_entry->name)) < Success) { if(err != Err_no_display) cant_query_driver(err,drv_entry->name); goto next_drv_entry; } mode_count = pj_vd_get_mode_count(drv); for(mode = 0;mode < mode_count;++mode) { if ((err = pj_vd_get_mode(drv,mode,&mode_info)) < Success) goto error; if(NULL == (mentry = *pmode_entry = pj_zalloc(sizeof(Mode_entry)))) { err = Err_no_memory; goto error; } mentry->mode_name = mentry->name_buf; mentry->drv_file = drv_entry->name; mentry->mode = mode; mentry->wrange = mode_info.width; mentry->hrange = mode_info.height; if(mode_info.width.min == mode_info.width.max) sprintf(wstr,"%d", mode_info.width.max); else { sprintf(wstr,"%d:%d", mode_info.width.min,mode_info.width.max); } if(mode_info.height.min == mode_info.height.max) sprintf(hstr,"%d", mode_info.height.max); else { sprintf(hstr,"%d:%d", mode_info.height.min,mode_info.height.max); } sprintf(mentry->name_buf, "%-12.12s %-2d %-18.18s %s X %s", mentry->drv_file, mode, mode_info.mode_name, wstr, hstr ); /* load pointer to current entry if found */ if(is_current && mode == vconfg.smode.mode) *pcurrent = (Names *)mentry; pmode_entry = (Mode_entry **)&(mentry->next); } next_drv_entry: if(!is_current) pj_close_vdriver(&drv); drv = NULL; drv_entry = drv_entry->next; } err = Success; goto done; error: free_mode_list(pmlist,pwildlist); done: if(!is_current) pj_close_vdriver(&drv); return(err); }
netclient::netclient(bool reliable,char *requeststring,char *host,word port,dword bandwidth,void (*_receiver)(netclient *client,byte packettype,byte *data,long size)) { reliable = false; if (!clientok) { connectionerror = net_tcpipna; return; } receiver = _receiver; netclientoem *oem = (netclientoem *)fcalloc(sizeof(netclientoem),"Network Client Connection"); oemdata = oem; if (reliable) oem->socket_type = SOCK_STREAM; // TCP else oem->socket_type = SOCK_DGRAM; // UDP // Attempt to detect if we should call gethostbyname() or gethostbyaddr() if (isalpha(host[0])) { // server address is a name oem->host = gethostbyname(host); } else { // Convert nnn.nnn address to a usable one dword addr = inet_addr(host); oem->host = gethostbyaddr((char *)&addr,4,AF_INET); } if (oem->host == NULL ) { //con->add("Client: Cannot resolve address [%s]: Error %d\n",host,WSAGetLastError()); connectionerror = net_cantresolveaddr; return; } oem->conn_socket = socket(AF_INET,oem->socket_type,0); // Open a socket if (oem->conn_socket <0 ) { //con->add("Client: Error Opening socket: Error %d\n",WSAGetLastError()); connectionerror = net_opensocketerror; return; } u_long argp = 1; if (ioctlsocket(oem->conn_socket,FIONBIO,&argp)) { connectionerror = net_ioctlfailed; closesocket(oem->conn_socket); return; } // // Notice that nothing in this code is specific to whether we // are using UDP or TCP. // We achieve this by using a simple trick. // When connect() is called on a datagram socket, it does not // actually establish the connection as a stream (TCP) socket // would. Instead, TCP/IP establishes the remote half of the // ( LocalIPAddress, LocalPort, RemoteIP, RemotePort) mapping. // This enables us to use send() and recv() on datagram sockets, // instead of recvfrom() and sendto() // // Copy the resolved information into the sockaddr_in structure // sockaddr_in server; memfill(&server,0,sizeof(server)); memcpy(&server.sin_addr,oem->host->h_addr,oem->host->h_length); server.sin_family = oem->host->h_addrtype; server.sin_port = htons(port); // Port Number //dword ip = *(dword *)oem->host->h_addr; //con->add("server IP = %i.%i.%i.%i, Port %i",(ip)&0xff,(ip>>8)&0xff,(ip>>16)&0xff,(ip>>24)&0xff,port); long retval = WSAEWOULDBLOCK; while (retval==WSAEWOULDBLOCK) { checkmsg(); retval = connect(oem->conn_socket,(struct sockaddr*)&server,sizeof(server)); if (retval == SOCKET_ERROR) { connectionerror = net_connectfailed; closesocket(oem->conn_socket); return; } } // Send initial request for a connection char *constring = buildstr("%s%8x",requeststring,bandwidth); retval = WSAEWOULDBLOCK; while (retval==WSAEWOULDBLOCK) { checkmsg(); //con->add("Send '%s' on Socket %i",requeststring,oem->conn_socket); // retval = send(oem->conn_socket,requeststring,txtlen(requeststring)+1,0); retval = send(oem->conn_socket,constring,txtlen(constring)+1,0); if (retval == SOCKET_ERROR) { connectionerror = net_hostlogin; closesocket(oem->conn_socket); return; } } retval = WSAEWOULDBLOCK; dword timeouttime = globalTimer + currentTimerHz * 2; while ((globalTimer<timeouttime) && (retval == WSAEWOULDBLOCK)) { checkmsg(); retval = recv(oem->conn_socket,(char *)&oem->Buffer[0],sizeof(oem->Buffer),0 ); if (retval == SOCKET_ERROR) { retval = WSAEWOULDBLOCK; //connectionerror = net_hostresponse; //closesocket(oem->conn_socket); //return; } if (retval == 0) { retval = WSAEWOULDBLOCK; } } if (globalTimer>=timeouttime) { connectionerror = net_timeout; closesocket(oem->conn_socket); return; } //con->add("Server says: %s\n",Buffer); long ofs = 0; char sep; char *token; token = gettoken((char *)oem->Buffer,&ofs,&sep); connectionerror = net_invalidresponse; if (txtcmp(token,"ServerFull")==0) connectionerror = net_serverfull; if (txtcmp(token,"ConnectionFailed")==0) connectionerror = net_servererror; if (txtcmp(token,"ConnectionGranted")==0) { port = (word)getuinttoken((char *)oem->Buffer,&ofs,&sep); oem->refnum = port; connectionerror = 0; return; } // con->add("%s",oem->Buffer); // con->add("Token = '%s', buffer = %s, length = %i",""/*token*/,oem->Buffer,retval); // con->add("Expected ConnectionGranted"); closesocket(oem->conn_socket); // ERROR ONLY! This line is not executed during normal execution }