void DOKUOBJ::save(HANDLE hFile) { save_object_basics(hFile, this); remove_nl(); save_property(hFile,"text",P_STRING,text); apply_nl(); }
void OpenShm() { printf ("Enter name: "); fgets (shm_name, sizeof (shm_name), stdin); remove_nl (shm_name); shm_addr = my_shm_open (shm_name); }
/*! \brief Re-poll a library command for symbols. * \par Function Description * Runs a library command, requesting a list of available symbols, * and updates the source with the new list. * * Private function used only in s_clib.c. */ static void refresh_command (CLibSource *source) { gchar *cmdout; TextBuffer *tb; const gchar *line; CLibSymbol *symbol; gchar *name; g_return_if_fail (source != NULL); g_return_if_fail (source->type == CLIB_CMD); /* Clear the current symbol list */ g_list_foreach (source->symbols, (GFunc) free_symbol, NULL); g_list_free (source->symbols); source->symbols = NULL; /* Run the command to get the list of symbols */ cmdout = run_source_command (source->list_cmd); if (cmdout == NULL) return; /* Use a TextBuffer to help reading out the lines of the output */ tb = s_textbuffer_new (cmdout, -1); while (1) { line = s_textbuffer_next_line (tb); if (line == NULL) break; if (line[0] == '.') continue; /* TODO is this sane? */ name = remove_nl(g_strdup(line)); /* skip symbols already known about */ if (source_has_symbol (source, name) != NULL) { g_free (name); continue; } symbol = g_new0 (CLibSymbol, 1); symbol->source = source; symbol->name = name; /* Prepend because it's faster and it doesn't matter what order we * add them. */ source->symbols = g_list_prepend (source->symbols, symbol); } s_textbuffer_free (tb); g_free (cmdout); /* Sort all symbols by name. */ source->symbols = g_list_sort (source->symbols, (GCompareFunc) compare_symbol_name); s_clib_flush_search_cache(); s_clib_flush_symbol_cache(); }
//loads the book database int load_saved_books() { FILE *fp2 = fopen("saves.liborder", "r"); char checkerc[100]; int i = 0; int fields = 0; while (1) { fgets(checkerc, 100, fp2); remove_nl(checkerc); //determining at which fields the chars are inserted if (feof(fp2)) { break; } if (i % 3 == 0) { change_is_used(fields,1); change_author(fields, checkerc); //printf("auth: %s",get_book(fields).author); } if (i % 3 == 1) { change_title(fields, checkerc); //printf(gb.title); } if (i % 3 == 2) { long long ibni = atol(checkerc); change_ibn(fields,ibni); if (get_head() == -1) { change_head(fields); change_tail(fields); change_next (fields, -1); } else { change_next(get_tail(), fields); change_tail(fields); change_next(fields, -1); } //printf("ibn: %lld\n",ibni); fields++; } i++; } fclose(fp2); return BOOK_OK; }
int main (int argc, char *argv[]) { int sock; /* Socket descriptor */ char echoBuffer[RCVBUFSIZE]; /* Buffer for received string */ int bytesRcvd; /* Bytes read in single recv() */ int bytesSend; /* Bytes read in single send() */ char line[80]; /* String entered by user to send to server */ parse_args (argc, argv); sock = CreateTCPClientSocket (argv_ip, argv_port); while (strcmp (line, "Quit") != 0) { /* Send message to server */ fgets (line, sizeof (line), stdin); remove_nl (line); info_s ("Entered: ", line); bytesSend = send (sock, line, strlen (line), 0); if (bytesSend < 0) { DieWithError ("send() failed"); } /* Receive message from server */ if(strcmp (line, "Quit") != 0) { bytesRcvd = recv (sock, echoBuffer, RCVBUFSIZE-1, 0); if (bytesRcvd < 0) { DieWithError ("recv() failed"); } if (bytesRcvd > 0) { add_nt (echoBuffer, bytesRcvd); printf ("Received: %s\n", echoBuffer); } } } delaying (); close (sock); info ("close & exit"); exit (0); }
static void mkmarshal() { char line[2048], *name, *ret, *param; out_head(); while (fgets(line, sizeof(line), fin) != NULL && !feof(fin) && !ferror(fin)) { remove_nl(line); if (!parse_line(line, &name, &ret, ¶m)) continue; out_func_prototype(name); out_func_body(name, ret, param); } out_bottom(); }