/* Helper function for foldercheck_insert_gnode_in_store */ static void foldercheck_append_item(GtkTreeStore *store, FolderItem *item, GtkTreeIter *iter, GtkTreeIter *parent) { gchar *name, *tmpname; GdkPixbuf *pixbuf, *pixbuf_open; name = tmpname = folder_item_get_name(item); if (item->stype != F_NORMAL && FOLDER_IS_LOCAL(item->folder)) { switch (item->stype) { case F_INBOX: if (!strcmp2(item->name, INBOX_DIR)) name = "Inbox"; break; case F_OUTBOX: if (!strcmp2(item->name, OUTBOX_DIR)) name = "Sent"; break; case F_QUEUE: if (!strcmp2(item->name, QUEUE_DIR)) name = "Queue"; break; case F_TRASH: if (!strcmp2(item->name, TRASH_DIR)) name = "Trash"; break; case F_DRAFT: if (!strcmp2(item->name, DRAFT_DIR)) name = "Drafts"; break; default: break; } } if (folder_has_parent_of_type(item, F_QUEUE) && item->total_msgs > 0) { name = g_strdup_printf("%s (%d)", name, item->total_msgs); } else if (item->unread_msgs > 0) { name = g_strdup_printf("%s (%d)", name, item->unread_msgs); } else name = g_strdup(name); pixbuf = item->no_select ? foldernoselect_pixbuf : folder_pixbuf; pixbuf_open = item->no_select ? foldernoselectopen_pixbuf : folderopen_pixbuf; /* insert this node */ gtk_tree_store_append(store, iter, parent); gtk_tree_store_set(store, iter, FOLDERCHECK_FOLDERNAME, name, FOLDERCHECK_FOLDERITEM, item, FOLDERCHECK_PIXBUF, pixbuf, FOLDERCHECK_PIXBUF_OPEN, pixbuf_open, -1); g_free(tmpname); }
static gboolean prefs_custom_header_selected(GtkTreeSelection *selector, GtkTreeModel *model, GtkTreePath *path, gboolean currently_selected, gpointer data) { GtkTreeIter iter; CustomHeader *ch; GtkImage *preview; GdkPixbuf *pixbuf; CustomHeader default_ch = { 0, "", NULL }; if (currently_selected) return TRUE; if (!gtk_tree_model_get_iter(model, &iter, path)) return TRUE; gtk_tree_model_get(model, &iter, CUSTHDR_DATA, &ch, -1); if (!ch) ch = &default_ch; ENTRY_SET_TEXT(customhdr.hdr_entry, ch->name); ENTRY_SET_TEXT(customhdr.val_entry, ch->value); if (!strcmp2("Face",ch->name)) { preview = GTK_IMAGE(face_get_from_header (ch->value)); pixbuf = gtk_image_get_pixbuf(preview); gtk_image_set_from_pixbuf (GTK_IMAGE(customhdr.preview), pixbuf); gtk_widget_show(customhdr.preview); #if GLIB_CHECK_VERSION(2,10,0) g_object_ref_sink (G_OBJECT(preview)); #else gtk_object_ref (G_OBJECT(preview)); gtk_object_sink (G_OBJECT(preview)); #endif } #if HAVE_LIBCOMPFACE else if (!strcmp2("X-Face", ch->name)) { preview = GTK_IMAGE(xface_get_from_header(ch->value)); pixbuf = gtk_image_get_pixbuf(preview); gtk_image_set_from_pixbuf (GTK_IMAGE(customhdr.preview), pixbuf); gtk_widget_show(customhdr.preview); #if GLIB_CHECK_VERSION(2,10,0) g_object_ref_sink (G_OBJECT(preview)); #else gtk_object_ref (G_OBJECT(preview)); gtk_object_sink (G_OBJECT(preview)); #endif } #endif else { gtk_widget_hide(customhdr.preview); } return TRUE; }
McoStatus CalCurves::importTone(char *fname) { int n,i,j,l; FILE *fs; char junk[255]; int numt = -1; fs = fopen( (char*)fname, "r" ); if(!fs) return MCO_FAILURE; fgets(junk,50,fs); n = strcmp2(junk,"DryJet Tone Curve\n"); if (n) return MCO_FILE_DATA_ERROR; fgets(tonename,99,fs); l = strlen(tonename); tonename[l-1] = 0; fscanf(fs,"%d\n",&numt); if (numt != numtone) {fclose(fs); return MCO_FAILURE;} for (i=0; i<numtone; i++) { fscanf(fs,"%d\n",&numToneHand[i]); if (numToneHand[i] > MAX_TONE_HAND) {fclose(fs); return MCO_FAILURE;} for (j=0; j<numToneHand[i]; j++) { fscanf(fs,"%lf %lf\n",&toneX[i*MAX_TONE_HAND+j],&toneY[i*MAX_TONE_HAND+j]); } } fclose(fs); return MCO_SUCCESS; }
/* Helper function to be used with a foreach statement of the model. Checks * if a node is checked, and adds it to a list if it is. data us a (GSList**) * where the result it to be stored */ static gboolean foldercheck_foreach_update_to_list(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data) { gchar *ident_tree, *ident_list; FolderItem *item; GSList *walk; gboolean toggle_item = FALSE; SpecificFolderArrayEntry *entry = (SpecificFolderArrayEntry*) data; gtk_tree_model_get(model, iter, FOLDERCHECK_FOLDERITEM, &item, -1); if(item->path != NULL) ident_tree = folder_item_get_identifier(item); else return FALSE; for(walk = entry->list; walk != NULL; walk = g_slist_next(walk)) { FolderItem *list_item = (FolderItem*) walk->data; ident_list = folder_item_get_identifier(list_item); if(!strcmp2(ident_list,ident_tree)) { toggle_item = TRUE; g_free(ident_list); break; } g_free(ident_list); } g_free(ident_tree); gtk_tree_store_set(entry->tree_store, iter, FOLDERCHECK_CHECK, toggle_item, -1); return FALSE; }
fivePointFive() { /* s is an array while p is a point, the case below show the difference. * The same thing for them is both them can visit value by adding steps.*/ char s[] = "i love you"; /* s can not be refered to another address, but string content can be modified.*/ // s = "iii"; //this will cause a compile error, for s is not a pointer. *(s + 1) = 'i'; // this is well, because for an array, the value can be modified. printf("%s %c\n", s, *s); char *p = "i love you"; /* p can be refered to another address, but string content can not be modified. */ p = "you love me"; // this is well, because p is a point, not a name of array. // *(p + 1) = 'u'; // this will cause a runtime error, for p can not modify the value. printf("%s %c\n", p, *p); // char *p = "you love me"; p will be pointed to an anonymous string, so it can't modify the value. // s = p; s++; //this will cause a compile error, for s is not a pointer. p = s; /* p now refered to an array and can be used just like s to modify the string content.*/ *(p + 1) = ' '; printf("%s\n", p); // char *ss = "123"; This will cause a runtime error, for ss should be an array which its value is allowed to be modified. char ss[10] = "123"; char *tt = "456"; // Here, use pointer is ok, for we just visit the value, no modification. printf("%s compared with %s: %d\n", ss, tt, strcmp(ss, tt)); strcpy(ss, tt); strcpy1(ss, tt); strcpy2(ss, tt); strcpy3(ss, tt); strcpy4(ss, tt); printf("copy tt to ss get %s\n", ss); printf("%s compared with %s: %d\n", ss, tt, strcmp2(ss, tt)); }
static void prefs_themes_get_themes_and_names(ThemesData *tdata) { GList *tpaths; cm_return_if_fail(tdata != NULL); if (tdata->themes != NULL) stock_pixmap_themes_list_free(tdata->themes); if (tdata->names != NULL) prefs_themes_free_names(tdata); tdata->themes = stock_pixmap_themes_list_new(); tpaths = tdata->themes; while (tpaths != NULL) { ThemeName *name = g_new0(ThemeName, 1); gchar *sname = g_path_get_basename((const gchar *)(tpaths->data)); if (IS_INTERNAL_THEME(sname)) name->name = g_strdup(_("Default internal theme")); else name->name = g_strdup(sname); name->item = tpaths; tdata->names = g_list_append(tdata->names, name); if (!strcmp2(tpaths->data, prefs_common.pixmap_theme_path)) { tdata->displayed = (gchar *)tpaths->data; } tpaths = g_list_next(tpaths); g_free(sname); } }
static void foldersel_set_tree(Folder *cur_folder, FolderSelectionType type) { Folder *folder; GList *list; for (list = folder_get_list(); list != NULL; list = list->next) { folder = FOLDER(list->data); cm_return_if_fail(folder != NULL); if (type != FOLDER_SEL_ALL) { if (FOLDER_TYPE(folder) == F_NEWS) continue; } if (cur_folder && (cur_folder->klass != folder->klass && strcmp2(cur_folder->name, folder->name) != 0)) continue; foldersel_insert_gnode_in_store(tree_store, folder->node, NULL); } gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(tree_store), FOLDERSEL_FOLDERNAME, GTK_SORT_ASCENDING); gtk_tree_view_expand_all(GTK_TREE_VIEW(treeview)); }
/** * Prepare completion index. This function should be called prior to attempting * address completion. * \return The number of addresses in the completion list. */ gint start_address_completion(gchar *folderpath) { gboolean different_book = FALSE; clear_completion_cache(); if (strcmp2(completion_folder_path,folderpath)) different_book = TRUE; g_free(completion_folder_path); if (folderpath != NULL) completion_folder_path = g_strdup(folderpath); else completion_folder_path = NULL; if (!g_ref_count) { init_all(); /* open the address book */ read_address_book(folderpath); } else if (different_book) read_address_book(folderpath); g_ref_count++; debug_print("start_address_completion(%s) ref count %d\n", folderpath?folderpath:"(null)", g_ref_count); return g_list_length(g_completion_list); }
int main() { char *s = "Hello a"; char *t = "Hell"; printf("%d\n", strcmp1(s, t)); printf("%d\n", strcmp2(s, t)); }
int main(void) { char x[20] = "abcdef"; char y[20] = "abcdefgfds"; int same = 0; same = strcmp2(x,y); if(same) printf("Strings are not equal!\n"); else printf("Strings are equal!\n"); }
/* Creates an entry in the specific_folder_array, and fills it with a new * SpecificFolderArrayEntry*. If specific_folder_array already has an entry * with the same name, return its ID. (The ID is the index in the array.) */ guint notification_register_folder_specific_list(gchar *node_name) { SpecificFolderArrayEntry *entry; gint ii = 0; /* If array does not yet exist, create it. */ if(!specific_folder_array) { specific_folder_array = g_array_new(FALSE, FALSE, sizeof(SpecificFolderArrayEntry*)); specific_folder_array_size = 0; /* Register hook for folder update */ /* "The hook is registered" is bound to "the array is allocated" */ hook_folder_update = hooks_register_hook(FOLDER_UPDATE_HOOKLIST, my_folder_update_hook, NULL); if(hook_folder_update == (guint) -1) { debug_print("Warning: Failed to register hook to folder update " "hooklist. " "Strange things can occur when deleting folders.\n"); } } /* Check if we already have such a name. If so, return its id. */ while(ii < specific_folder_array_size) { entry = g_array_index(specific_folder_array,SpecificFolderArrayEntry*,ii); if(entry) { if(!strcmp2(entry->name,node_name)) return ii; } ii++; } /* Create an entry with the corresponding node name. */ entry = g_new(SpecificFolderArrayEntry, 1); entry->name = g_strdup(node_name); entry->list = NULL; entry->window = NULL; entry->treeview = NULL; entry->cancelled = FALSE; entry->finished = FALSE; entry->recursive = FALSE; entry->tree_store = gtk_tree_store_new(N_FOLDERCHECK_COLUMNS, G_TYPE_STRING, G_TYPE_POINTER, GDK_TYPE_PIXBUF, GDK_TYPE_PIXBUF, G_TYPE_BOOLEAN); gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(entry->tree_store), FOLDERCHECK_FOLDERNAME, foldercheck_folder_name_compare, NULL, NULL); specific_folder_array = g_array_append_val(specific_folder_array, entry); return specific_folder_array_size++; }
int main() { char s1[] = "test string1"; char s2[] = "test string"; char s3[] = "aaa"; char s4[] = "bbb"; printf("strcmp1(%s, %s) = %d \n", s1, s2, strcmp1(s1, s2)); printf("strcmp2(%s, %s) = %d \n", s3, s4, strcmp2(s3, s4)); return 0; }
/** * Inserts the given string in the given couple list. */ struct couple* insert_string(unichar* s, struct couple* couple, struct sort_infos* inf) { struct couple* tmp; if (couple == NULL || inf->REVERSE * strcmp2(s, couple->s, inf) < 0) { /* If we are at the end of the list, or if we have to insert */ tmp = new_couple(s); if(tmp) { tmp->next = couple; } return tmp; } if (!strcmp2(s, couple->s, inf)) { /* If the string is already in the list */ if (!inf->REMOVE_DUPLICATES) (couple->n)++; return couple; } /* If we have to explore the tail of the list */ couple->next = insert_string(s, couple->next, inf); return couple; }
main() { char p[] = "hello"; char t[] = "hdllo"; int value = strcmp(p, t); printf("%d\n", value); int value2 = strcmp2(p, t); printf("%d\n", value2); }
void scanf(char* str, void* buf) { //printf("hello\n"); char temp_buf[20]={'\0'}; read(0,temp_buf,20); if(strcmp2(str, "%s") == 0) { buf = (char *)buf; int i = 0; while(temp_buf[i] != '\0') *(char *)buf++ = temp_buf[i++]; *(char *)buf = '\0'; } else if(strcmp2(str, "%d") == 0) { *(int *)buf = stoi(temp_buf); } else if(strcmp2(str, "%x") == 0) { } }
CUser* CUserList::Find(const char* name) { int i; for (i = 0; i <= m_last; i++) { if (m_users[i]) { if (strcmp2(m_users[i]->m_name, name) == 0) return m_users[i]; } } return NULL; }
static void prefs_themes_set_themes_menu(GtkComboBox *combo, const ThemesData *tdata) { GtkListStore *store; GtkTreeIter iter; GList *themes = tdata->names; gint i = 0, active = 0; GList *sorted_list = NULL; cm_return_if_fail(combo != NULL); /* sort theme data list by data name */ while (themes != NULL) { ThemeName *tname = (ThemeName *)(themes->data); sorted_list = g_list_insert_sorted(sorted_list, (gpointer)(tname), (GCompareFunc)prefs_themes_cmp_name); themes = g_list_next(themes); } store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_POINTER); /* feed gtk_menu w/ sorted themes names */ themes = sorted_list; while (themes != NULL) { ThemeName *tname = (ThemeName *)(themes->data); gchar *tpath = (gchar *)(tname->item->data); gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, 0, tname->name, 1, tname->item->data, -1); if (tdata->displayed != NULL && !strcmp2(tdata->displayed,tpath)) active = i; ++i; themes = g_list_next(themes); } g_list_free(sorted_list); g_signal_connect(G_OBJECT(combo), "changed", G_CALLBACK(prefs_themes_menu_item_activated_cb), NULL); gtk_combo_box_set_model(combo, GTK_TREE_MODEL(store)); gtk_combo_box_set_active(combo, active); }
int dopragma (char *ln) { if (strcmp2 (ln, "asm ")) { if (cflag) puts ("#2"); else printf ("#pragma asm "); if (*(ln + 4) == '*') /* removes label field null character */ *(ln + 4) = ' '; printf ("%s\n", ln + 4); return (killine ()); } if (!cflag) printf ("#pragma %s\n", ln); return (killine ()); }
int main(void) { char s[100]; char *t = "Test strcpy;"; strcpy1(s,t); printf("%s\n", t); strcpy2(s,t); printf("%s\n", t); strcpy3(s,t); printf("%s\n", t); strcpy4(s,t); printf("%s\n", t); strcpy1(s+strlen1(s),t); printf("%s\n", s); printf("%d\n", strcmp1(s,t)); printf("%d\n", strcmp2(s,t)); return 0; }
void notification_trayicon_msg(MsgInfo *msginfo) { #ifndef HAVE_LIBNOTIFY return; #else FolderType ftype; NotificationFolderType nftype; gchar *uistr; nftype = F_TYPE_MAIL; if(!msginfo || !notify_config.trayicon_enabled || !notify_config.trayicon_popup_enabled || !MSG_IS_NEW(msginfo->flags)) return; if(notify_config.trayicon_folder_specific) { guint id; GSList *list; gchar *identifier; gboolean found = FALSE; if(!(msginfo->folder)) return; identifier = folder_item_get_identifier(msginfo->folder); id = notification_register_folder_specific_list (TRAYICON_SPECIFIC_FOLDER_ID_STR); list = notification_foldercheck_get_list(id); for(; (list != NULL) && !found; list = g_slist_next(list)) { gchar *list_identifier; FolderItem *list_item = (FolderItem*) list->data; list_identifier = folder_item_get_identifier(list_item); if(!strcmp2(list_identifier, identifier)) found = TRUE; g_free(list_identifier); } g_free(identifier); if(!found) return; } /* folder specific */ ftype = msginfo->folder->folder->klass->type; G_LOCK(trayicon_popup); /* Check out which type to notify about */ switch(ftype) { case F_MH: case F_MBOX: case F_MAILDIR: case F_IMAP: nftype = F_TYPE_MAIL; break; case F_NEWS: nftype = F_TYPE_NEWS; break; case F_UNKNOWN: if((uistr = msginfo->folder->folder->klass->uistr) == NULL) { G_UNLOCK(trayicon_popup); return; } else if(!strcmp(uistr, "vCalendar")) nftype = F_TYPE_CALENDAR; else if(!strcmp(uistr, "RSSyl")) nftype = F_TYPE_RSS; else { debug_print("Notification Plugin: Unknown folder type %d\n",ftype); G_UNLOCK(trayicon_popup); return; } break; default: debug_print("Notification Plugin: Unknown folder type %d\n",ftype); G_UNLOCK(trayicon_popup); return; } notification_trayicon_popup_add_msg(msginfo, nftype); G_UNLOCK(trayicon_popup); #endif /* HAVE_LIBNOTIFY */ }
static void foldersel_append_item(GtkTreeStore *store, FolderItem *item, GtkTreeIter *iter, GtkTreeIter *parent) { gchar *name, *tmpname; GdkPixbuf *pixbuf, *pixbuf_open; gboolean use_color; PangoWeight weight = PANGO_WEIGHT_NORMAL; GdkColor *foreground = NULL; static GdkColor color_noselect = {0, COLOR_DIM, COLOR_DIM, COLOR_DIM}; static GdkColor color_new; gtkut_convert_int_to_gdk_color(prefs_common.color_new, &color_new); name = tmpname = folder_item_get_name(item); if (item->stype != F_NORMAL && FOLDER_IS_LOCAL(item->folder)) { switch (item->stype) { case F_INBOX: if (!strcmp2(item->name, INBOX_DIR)) name = _("Inbox"); break; case F_OUTBOX: if (!strcmp2(item->name, OUTBOX_DIR)) name = _("Sent"); break; case F_QUEUE: if (!strcmp2(item->name, QUEUE_DIR)) name = _("Queue"); break; case F_TRASH: if (!strcmp2(item->name, TRASH_DIR)) name = _("Trash"); break; case F_DRAFT: if (!strcmp2(item->name, DRAFT_DIR)) name = _("Drafts"); break; default: break; } } if (folder_has_parent_of_type(item, F_QUEUE) && item->total_msgs > 0) { name = g_strdup_printf("%s (%d)", name, item->total_msgs); } else if (item->unread_msgs > 0) { name = g_strdup_printf("%s (%d)", name, item->unread_msgs); } else name = g_strdup(name); pixbuf = item->no_select ? foldernoselect_pixbuf : folder_pixbuf; pixbuf_open = item->no_select ? foldernoselectopen_pixbuf : folderopen_pixbuf; if (folder_has_parent_of_type(item, F_DRAFT) || folder_has_parent_of_type(item, F_OUTBOX) || folder_has_parent_of_type(item, F_TRASH)) { use_color = FALSE; } else if (folder_has_parent_of_type(item, F_QUEUE)) { use_color = (item->total_msgs > 0); if (item->total_msgs > 0) weight = PANGO_WEIGHT_BOLD; } else { if (item->unread_msgs > 0) weight = PANGO_WEIGHT_BOLD; use_color = (item->new_msgs > 0); } if (item->no_select) foreground = &color_noselect; else if (use_color) foreground = &color_new; /* insert this node */ gtk_tree_store_append(store, iter, parent); gtk_tree_store_set(store, iter, FOLDERSEL_FOLDERNAME, name, FOLDERSEL_FOLDERITEM, item, FOLDERSEL_PIXBUF, pixbuf, FOLDERSEL_PIXBUF_OPEN, pixbuf_open, FOLDERSEL_FOREGROUND, foreground, FOLDERSEL_BOLD, weight, -1); g_free(tmpname); }
void frdset(char *filabl,char *set,int *iset,int *istartset,int *iendset, int *ialset,int *inum,int *noutloc,int *nout,int *nset, int *noutmin,int *noutplus,int *iselect,int *ngraph){ int j,k; char noset[81]; /* check for a set, if any */ strcpy1(noset,&filabl[6],81); for((*iset)=0;(*iset)<(*nset);(*iset)++){ if(strcmp2(&set[81**iset],noset,81)==0) break; } (*iset)++; if(*iset>*nset)*iset=0; // printf("iset,noutplus %d %d\n",*iset,*noutplus); /* determining the number of nodes in the set */ if(*iset==0){ /* no set defined */ // printf("iselect,noutplus %d %d\n",*iselect,*noutplus); if(*iselect==1){ *noutloc=*noutplus; }else if(*iselect==-1){ *noutloc=*noutmin; }else{ *noutloc=*nout; } }else{ /* a set was defined */ *noutloc=0; for(j=istartset[*iset-1]-1;j<iendset[*iset-1];j++){ if(ialset[j]>0){ if(*iselect==-1){ if(inum[ialset[j]-1]<0) (*noutloc)++; }else if(*iselect==1){ if(inum[ialset[j]-1]>0) (*noutloc)++; }else{ if(inum[ialset[j]-1]!=0) (*noutloc)++; } }else{ k=ialset[j-2]; do{ k=k-ialset[j]; if(k>=ialset[j-1]) break; if(*iselect==-1){ if(inum[k-1]<0) (*noutloc)++; }else if(*iselect==1){ if(inum[k-1]>0) (*noutloc)++; }else{ if(inum[k-1]!=0) (*noutloc)++; } }while(1); } } if(*ngraph>1) (*noutloc)*=(*ngraph); } }
static void mh_scan_tree_recursive(FolderItem *item) { Folder *folder; #ifdef G_OS_WIN32 GDir *dir; #else DIR *dp; struct dirent *d; #endif const gchar *dir_name; struct stat s; gchar *real_path, *entry, *utf8entry, *utf8name; gint n_msg = 0; cm_return_if_fail(item != NULL); cm_return_if_fail(item->folder != NULL); folder = item->folder; real_path = item->path ? mh_filename_from_utf8(item->path) : g_strdup("."); #ifdef G_OS_WIN32 dir = g_dir_open(real_path, 0, NULL); if (!dir) { g_warning("failed to open directory: %s\n", real_path); g_free(real_path); return; } #else dp = opendir(real_path); if (!dp) { FILE_OP_ERROR(real_path, "opendir"); return; } #endif g_free(real_path); debug_print("scanning %s ...\n", item->path ? item->path : LOCAL_FOLDER(item->folder)->rootpath); if (folder->ui_func) folder->ui_func(folder, item, folder->ui_func_data); #ifdef G_OS_WIN32 while ((dir_name = g_dir_read_name(dir)) != NULL) { #else while ((d = readdir(dp)) != NULL) { dir_name = d->d_name; #endif if (dir_name[0] == '.') continue; utf8name = mh_filename_to_utf8(dir_name); if (item->path) utf8entry = g_strconcat(item->path, G_DIR_SEPARATOR_S, utf8name, NULL); else utf8entry = g_strdup(utf8name); entry = mh_filename_from_utf8(utf8entry); if ( #if !defined(G_OS_WIN32) && defined(HAVE_DIRENT_D_TYPE) d->d_type == DT_DIR || (d->d_type == DT_UNKNOWN && #endif g_stat(entry, &s) == 0 && S_ISDIR(s.st_mode) #if !defined(G_OS_WIN32) && defined(HAVE_DIRENT_D_TYPE) ) #endif ) { FolderItem *new_item = NULL; GNode *node; node = item->node; for (node = node->children; node != NULL; node = node->next) { FolderItem *cur_item = FOLDER_ITEM(node->data); gchar *curpath = mh_filename_from_utf8(cur_item->path); if (!strcmp2(curpath, entry)) { new_item = cur_item; g_free(curpath); break; } g_free(curpath); } if (!new_item) { debug_print("new folder '%s' found.\n", entry); new_item = folder_item_new(folder, utf8name, utf8entry); folder_item_append(item, new_item); } if (!item->path) { if (!folder->inbox && !strcmp(dir_name, INBOX_DIR)) { new_item->stype = F_INBOX; folder->inbox = new_item; } else if (!folder->outbox && !strcmp(dir_name, OUTBOX_DIR)) { new_item->stype = F_OUTBOX; folder->outbox = new_item; } else if (!folder->draft && !strcmp(dir_name, DRAFT_DIR)) { new_item->stype = F_DRAFT; folder->draft = new_item; } else if (!folder->queue && !strcmp(dir_name, QUEUE_DIR)) { new_item->stype = F_QUEUE; folder->queue = new_item; } else if (!folder->trash && !strcmp(dir_name, TRASH_DIR)) { new_item->stype = F_TRASH; folder->trash = new_item; } } mh_scan_tree_recursive(new_item); } else if (to_number(dir_name) > 0) n_msg++; g_free(entry); g_free(utf8entry); g_free(utf8name); } #ifdef G_OS_WIN32 g_dir_close(dir); #else closedir(dp); #endif mh_set_mtime(folder, item); } static gboolean mh_rename_folder_func(GNode *node, gpointer data) { FolderItem *item = node->data; gchar **paths = data; const gchar *oldpath = paths[0]; const gchar *newpath = paths[1]; gchar *base; gchar *new_itempath; gint oldpathlen; oldpathlen = strlen(oldpath); if (strncmp(oldpath, item->path, oldpathlen) != 0) { g_warning("path doesn't match: %s, %s\n", oldpath, item->path); return TRUE; } base = item->path + oldpathlen; while (*base == G_DIR_SEPARATOR) base++; if (*base == '\0') new_itempath = g_strdup(newpath); else new_itempath = g_strconcat(newpath, G_DIR_SEPARATOR_S, base, NULL); g_free(item->path); item->path = new_itempath; return FALSE; }
/* Read selections from a common xml-file. Called when loading the plugin. * Returns TRUE if data has been read, FALSE if no data is available * or an error occurred. * This is analog to folder.h::folder_read_list. */ gboolean notification_foldercheck_read_array(void) { gchar *path; GNode *rootnode, *node, *branchnode; XMLNode *xmlnode; gboolean success = FALSE; path = foldercheck_get_array_path(); if(!is_file_exist(path)) { path = NULL; return FALSE; } /* We don't do merging, so if the file existed, clear what we have stored in memory right now.. */ notification_free_folder_specific_array(); /* .. and evaluate the file */ rootnode = xml_parse_file(path); path = NULL; if(!rootnode) return FALSE; xmlnode = rootnode->data; /* Check that root entry is "foldercheckarray" */ if(strcmp2(xmlnode->tag->tag, "foldercheckarray") != 0) { g_warning("wrong foldercheck array file"); xml_free_tree(rootnode); return FALSE; } /* Process branch entries */ for(branchnode = rootnode->children; branchnode != NULL; branchnode = branchnode->next) { GList *list; guint id; SpecificFolderArrayEntry *entry = NULL; xmlnode = branchnode->data; if(strcmp2(xmlnode->tag->tag, "branch") != 0) { g_warning("tag name != \"branch\""); return FALSE; } /* Attributes of the branch nodes */ list = xmlnode->tag->attr; for(; list != NULL; list = list->next) { XMLAttr *attr = list->data; if(attr && attr->name && attr->value && !strcmp2(attr->name, "name")) { id = notification_register_folder_specific_list(attr->value); entry = foldercheck_get_entry_from_id(id); /* We have found something */ success = TRUE; break; } } if((list == NULL) || (entry == NULL)) { g_warning("Did not find attribute \"name\" in tag \"branch\""); continue; /* with next branch */ } /* Now descent into the children of the brach, which are the folderitems */ for(node = branchnode->children; node != NULL; node = node->next) { FolderItem *item = NULL; /* These should all be leaves. */ if(!G_NODE_IS_LEAF(node)) g_warning("Subnodes in \"branch\" nodes should all be leaves. " "Ignoring deeper subnodes."); /* Check if tag is "folderitem" */ xmlnode = node->data; if(strcmp2(xmlnode->tag->tag, "folderitem") != 0) { g_warning("tag name != \"folderitem\""); continue; /* to next node in branch */ } /* Attributes of the leaf nodes */ list = xmlnode->tag->attr; for(; list != NULL; list = list->next) { XMLAttr *attr = list->data; if(attr && attr->name && attr->value && !strcmp2(attr->name, "identifier")) { item = folder_find_item_from_identifier(attr->value); break; } } if((list == NULL) || (item == NULL)) { g_warning("Did not find attribute \"identifier\" in tag " "\"folderitem\""); continue; /* with next leaf node */ } /* Store all FolderItems in the list */ /* We started with a cleared array, so we don't need to check if it's already in there. */ entry->list = g_slist_prepend(entry->list, item); } /* for all subnodes in branch */ } /* for all branches */ return success; }
static void tox_thread_message(Tox *tox, ToxAv *av, uint64_t time, uint8_t msg, uint16_t param1, uint16_t param2, void *data) { switch(msg) { case TOX_SETNAME: { /* param1: name length * data: name */ tox_set_name(tox, data, param1); break; } case TOX_SETSTATUSMSG: { /* param1: status length * data: status message */ tox_set_status_message(tox, data, param1); break; } case TOX_SETSTATUS: { /* param1: status */ tox_set_user_status(tox, param1); break; } case TOX_ADDFRIEND: { /* param1: length of message * data: friend id + message */ int r; if(!param1) { STRING* default_add_msg = SPTR(DEFAULT_FRIEND_REQUEST_MESSAGE); r = tox_add_friend(tox, data, default_add_msg->str, default_add_msg->length); } else { r = tox_add_friend(tox, data, data + TOX_FRIEND_ADDRESS_SIZE, param1); } if(r < 0) { uint8_t addf_error; switch(r) { case TOX_FAERR_TOOLONG: addf_error = ADDF_TOOLONG; break; case TOX_FAERR_NOMESSAGE: addf_error = ADDF_NOMESSAGE; break; case TOX_FAERR_OWNKEY: addf_error = ADDF_OWNKEY; break; case TOX_FAERR_ALREADYSENT: addf_error = ADDF_ALREADYSENT; break; case TOX_FAERR_BADCHECKSUM: addf_error = ADDF_BADCHECKSUM; break; case TOX_FAERR_SETNEWNOSPAM: addf_error = ADDF_SETNEWNOSPAM; break; case TOX_FAERR_NOMEM: addf_error = ADDF_NOMEM; break; case TOX_FAERR_UNKNOWN: default: addf_error = ADDF_UNKNOWN; break; } postmessage(FRIEND_ADD, 1, addf_error, data); } else { postmessage(FRIEND_ADD, 0, r, data); } break; } case TOX_DELFRIEND: { /* param1: friend # */ tox_del_friend(tox, param1); postmessage(FRIEND_DEL, 0, 0, data); break; } case TOX_ACCEPTFRIEND: { /* data: FRIENDREQ */ FRIENDREQ *req = data; int r = tox_add_friend_norequest(tox, req->id); postmessage(FRIEND_ACCEPT, (r < 0), (r < 0) ? 0 : r, req); break; } case TOX_SENDMESSAGE: { /* param1: friend # * param2: message length * data: message */ log_write(tox, param1, data, param2, 1, LOG_FILE_MSG_TYPE_TEXT); void *p = data; while(param2 > TOX_MAX_MESSAGE_LENGTH) { uint16_t len = TOX_MAX_MESSAGE_LENGTH - utf8_unlen(p + TOX_MAX_MESSAGE_LENGTH); tox_send_message(tox, param1, p, len); param2 -= len; p += len; } tox_send_message(tox, param1, p, param2); free(data); break; } case TOX_SENDACTION: { /* param1: friend # * param2: message length * data: message */ log_write(tox, param1, data, param2, 1, LOG_FILE_MSG_TYPE_ACTION); void *p = data; while(param2 > TOX_MAX_MESSAGE_LENGTH) { uint16_t len = TOX_MAX_MESSAGE_LENGTH - utf8_unlen(p + TOX_MAX_MESSAGE_LENGTH); tox_send_action(tox, param1, p, len); param2 -= len; p += len; } tox_send_action(tox, param1, p, param2); free(data); break; } case TOX_SENDMESSAGEGROUP: { /* param1: group # * param2: message length * data: message */ tox_group_message_send(tox, param1, data, param2); free(data); break; } case TOX_SENDACTIONGROUP: { /* param1: group # * param2: message length * data: message */ tox_group_action_send(tox, param1, data, param2); free(data); } case TOX_SET_TYPING: { /* param1: friend # */ // Check if user has switched to another friend window chat. // Take care not to react on obsolete data from old Tox instance. _Bool need_resetting = (typing_state.tox == tox) && (typing_state.friendnumber != param1) && (typing_state.sent_value); if(need_resetting) { // Tell previous friend that he's betrayed. tox_set_user_is_typing(tox, typing_state.friendnumber, 0); // Mark that new friend doesn't know that we're typing yet. typing_state.sent_value = 0; } // Mark us as typing to this friend at the moment. // utox_thread_work_for_typing_notifications() will // send a notification if it deems necessary. typing_state.tox = tox; typing_state.friendnumber = param1; typing_state.time = time; //debug("Set typing state for friend (%d): %d\n", typing_state.friendnumber, typing_state.sent_value); break; } case TOX_CALL: { /* param1: friend # */ int32_t id; toxav_call(av, &id, param1, &av_DefaultSettings, 10); postmessage(FRIEND_CALL_STATUS, param1, id, (void*)CALL_RINGING); break; } case TOX_CALL_VIDEO: { /* param1: friend # */ ToxAvCSettings settings = av_DefaultSettings; settings.call_type = av_TypeVideo; settings.max_video_width = max_video_width; settings.max_video_height = max_video_height; int32_t id; toxav_call(av, &id, param1, &settings, 10); postmessage(FRIEND_CALL_STATUS, param1, id, (void*)CALL_RINGING_VIDEO); break; } case TOX_CALL_VIDEO_ON: { /* param1: friend # * param2: call # */ ToxAvCSettings settings = av_DefaultSettings; settings.call_type = av_TypeVideo; settings.max_video_width = max_video_width; settings.max_video_height = max_video_height; toxav_change_settings(av, param2, &settings); postmessage(FRIEND_CALL_START_VIDEO, param1, param2, NULL); break; } case TOX_CALL_VIDEO_OFF: { /* param1: friend # * param2: call # */ toxav_change_settings(av, param2, &av_DefaultSettings); postmessage(FRIEND_CALL_STOP_VIDEO, param1, param2, NULL); break; } case TOX_ACCEPTCALL: { /* param1: call # */ ToxAvCSettings settings = av_DefaultSettings; if(param2) { settings.call_type = av_TypeVideo; settings.max_video_width = max_video_width; settings.max_video_height = max_video_height; } toxav_answer(av, param1, &settings); break; } case TOX_HANGUP: { /* param1: call # */ toxav_hangup(av, param1); break; } case TOX_NEWGROUP: { /* */ int g = -1; if (param1) { g = toxav_add_av_groupchat(tox, &callback_av_group_audio, NULL); } else { g = tox_add_groupchat(tox); } if(g != -1) { postmessage(GROUP_ADD, g, 0, tox); } break; } case TOX_LEAVEGROUP: { /* param1: group # */ tox_del_groupchat(tox, param1); break; } case TOX_GROUPINVITE: { /* param1: group # * param2: friend # */ tox_invite_friend(tox, param2, param1); break; } case TOX_GROUPCHANGETOPIC: { /* param1: group # * param2: topic length * data: topic */ tox_group_set_title(tox, param1, data, param2); postmessage(GROUP_TITLE, param1, param2, data); break; } case TOX_GROUP_AUDIO_START:{ /* param1: group # */ postmessage(GROUP_AUDIO_START, param1, 0, NULL); break; } case TOX_GROUP_AUDIO_END:{ /* param1: group # */ postmessage(GROUP_AUDIO_END, param1, 0, NULL); break; } case TOX_SENDFILES: { /* param1: friend # * param2: offset of first file name in data * data: file names */ if(param2 == 0xFFFF) { //paths with line breaks uint8_t *name = data, *p = data, *s = name; while(*p) { _Bool end = 1; while(*p) { if(*p == '\n') { *p = 0; end = 0; break; } if(*p == '/' || *p == '\\') { s = p + 1; } p++; } if(strcmp2(name, "file://") == 0) { name += 7; } utox_transfer_start_file(tox, param1, name, s, p - s); p++; s = name = p; if(end) { break; } } } else { //windows path list uint8_t *name = data; _Bool multifile = (name[param2 - 1] == 0); if(!multifile) { utox_transfer_start_file(tox, param1, data, data + param2, strlen(data) - param2); } else { uint8_t *p = name + param2; name += param2 - 1; if(*(name - 1) != '\\') { *name++ = '\\'; } while(*p) { int len = strlen((char*)p) + 1; memmove(name, p, len); p += len; utox_transfer_start_file(tox, param1, data, name, len - 1); } } } free(data); break; } case TOX_SEND_INLINE: { /* param1: friend id data: pointer to a TOX_SEND_INLINE_MSG struct */ struct TOX_SEND_INLINE_MSG *tsim = data; utox_transfer_start_memory(tox, param1, tsim->image->png_data, tsim->image_size); free(tsim); break; } case TOX_ACCEPTFILE: { /* param1: friend # * param2: file # * data: path to write file */ FILE_T *ft = &friend[param1].incoming[param2]; ft->data = fopen(data, "wb"); if(!ft->data) { free(data); break; } ft->path = data; ft->status = FT_SEND; tox_file_send_control(tox, param1, 1, param2, TOX_FILECONTROL_ACCEPT, NULL, 0); postmessage(FRIEND_FILE_IN_STATUS, param1, param2, (void*)FILE_OK); break; } case TOX_FILE_IN_CANCEL: { /* param1: friend # * param2: file # */ FILE_T *ft = &friend[param1].incoming[param2]; if(ft->data) { if(ft->inline_png) { free(ft->data); } else { fclose(ft->data); free(ft->path); } } ft->status = FT_NONE; tox_file_send_control(tox, param1, 1, param2, TOX_FILECONTROL_KILL, NULL, 0); postmessage(FRIEND_FILE_IN_STATUS, param1, param2, (void*)FILE_KILLED); break; } case TOX_FILE_OUT_CANCEL: { /* param1: friend # * param2: file # */ FILE_T *ft = &friend[param1].outgoing[param2]; ft->status = FT_KILL; tox_file_send_control(tox, param1, 0, param2, TOX_FILECONTROL_KILL, NULL, 0); postmessage(FRIEND_FILE_OUT_STATUS, param1, param2, (void*)FILE_KILLED); break; } case TOX_FILE_IN_PAUSE: { /* param1: friend # * param2: file # */ tox_file_send_control(tox, param1, 1, param2, TOX_FILECONTROL_PAUSE, NULL, 0); postmessage(FRIEND_FILE_IN_STATUS, param1, param2, (void*)FILE_PAUSED); break; } case TOX_FILE_OUT_PAUSE: { /* param1: friend # * param2: file # */ FILE_T *ft = &friend[param1].outgoing[param2]; ft->status = FT_PAUSE; tox_file_send_control(tox, param1, 0, param2, TOX_FILECONTROL_PAUSE, NULL, 0); postmessage(FRIEND_FILE_OUT_STATUS, param1, param2, (void*)FILE_PAUSED); break; } case TOX_FILE_IN_RESUME: { /* param1: friend # * param2: file # */ tox_file_send_control(tox, param1, 1, param2, TOX_FILECONTROL_ACCEPT, NULL, 0); postmessage(FRIEND_FILE_IN_STATUS, param1, param2, (void*)FILE_OK); break; } case TOX_FILE_OUT_RESUME: { /* param1: friend # * param2: file # */ FILE_T *ft = &friend[param1].outgoing[param2]; ft->status = FT_SEND; tox_file_send_control(tox, param1, 0, param2, TOX_FILECONTROL_ACCEPT, NULL, 0); postmessage(FRIEND_FILE_OUT_STATUS, param1, param2, (void*)FILE_OK); break; } } }
static void mh_scan_tree_recursive(FolderItem *item) { Folder *folder; GDir *dir; const gchar *dir_name; gchar *real_path, *entry, *utf8entry, *utf8name; gint n_msg = 0; GError *error = NULL; cm_return_if_fail(item != NULL); cm_return_if_fail(item->folder != NULL); folder = item->folder; real_path = item->path ? mh_filename_from_utf8(item->path) : g_strdup("."); dir = g_dir_open(real_path, 0, &error); if (!dir) { g_warning("failed to open directory '%s': %s (%d)", real_path, error->message, error->code); g_error_free(error); g_free(real_path); return; } g_free(real_path); debug_print("scanning %s ...\n", item->path ? item->path : LOCAL_FOLDER(item->folder)->rootpath); if (folder->ui_func) folder->ui_func(folder, item, folder->ui_func_data); while ((dir_name = g_dir_read_name(dir)) != NULL) { if (dir_name[0] == '.') continue; utf8name = mh_filename_to_utf8(dir_name); if (item->path) utf8entry = g_strconcat(item->path, G_DIR_SEPARATOR_S, utf8name, NULL); else utf8entry = g_strdup(utf8name); entry = mh_filename_from_utf8(utf8entry); if (g_file_test(entry, G_FILE_TEST_IS_DIR)) { FolderItem *new_item = NULL; GNode *node; node = item->node; for (node = node->children; node != NULL; node = node->next) { FolderItem *cur_item = FOLDER_ITEM(node->data); gchar *curpath = mh_filename_from_utf8(cur_item->path); if (!strcmp2(curpath, entry)) { new_item = cur_item; g_free(curpath); break; } g_free(curpath); } if (!new_item) { debug_print("new folder '%s' found.\n", entry); new_item = folder_item_new(folder, utf8name, utf8entry); folder_item_append(item, new_item); } if (!item->path) { if (!folder->inbox && !strcmp(dir_name, INBOX_DIR)) { new_item->stype = F_INBOX; folder->inbox = new_item; } else if (!folder->outbox && !strcmp(dir_name, OUTBOX_DIR)) { new_item->stype = F_OUTBOX; folder->outbox = new_item; } else if (!folder->draft && !strcmp(dir_name, DRAFT_DIR)) { new_item->stype = F_DRAFT; folder->draft = new_item; } else if (!folder->queue && !strcmp(dir_name, QUEUE_DIR)) { new_item->stype = F_QUEUE; folder->queue = new_item; } else if (!folder->trash && !strcmp(dir_name, TRASH_DIR)) { new_item->stype = F_TRASH; folder->trash = new_item; } } mh_scan_tree_recursive(new_item); } else if (to_number(dir_name) > 0) n_msg++; g_free(entry); g_free(utf8entry); g_free(utf8name); } g_dir_close(dir); mh_set_mtime(folder, item); }
static int prefs_themes_cmp_name(gconstpointer a_p, gconstpointer b_p) { /* compare two ThemeData structures by their name attribute */ return strcmp2((gchar *)(((ThemeName*)a_p)->name), (gchar *)(((ThemeName*)b_p)->name)); }
/*! *\brief */ gint stock_pixbuf_gdk(StockPixmap icon, GdkPixbuf **pixbuf) { StockPixmapData *pix_d; static const char *extension[]= {".png", ".xpm", NULL}; int i = 0; gboolean theme_changed = FALSE; if (pixbuf) *pixbuf = NULL; cm_return_val_if_fail(icon >= 0 && icon < N_STOCK_PIXMAPS, -1); pix_d = &pixmaps[icon]; theme_changed = (strcmp2(pix_d->icon_path, prefs_common.pixmap_theme_path) != 0); if (!pix_d->pixbuf || theme_changed) { GdkPixbuf *pix = NULL; if (theme_changed && pix_d->pixmap) { g_object_unref(pix_d->pixmap); pix_d->pixmap = NULL; } if (strcmp(prefs_common.pixmap_theme_path, DEFAULT_PIXMAP_THEME) != 0) { if (is_dir_exist(prefs_common.pixmap_theme_path)) { char *icon_file_name; try_next_extension: icon_file_name = g_strconcat(prefs_common.pixmap_theme_path, G_DIR_SEPARATOR_S, pix_d->file, extension[i], NULL); if (is_file_exist(icon_file_name)) { GError *err = NULL; pix = gdk_pixbuf_new_from_file(icon_file_name, &err); if (err) g_error_free(err); } if (pix) { g_free(pix_d->icon_path); pix_d->icon_path = g_strdup(prefs_common.pixmap_theme_path); } g_free(icon_file_name); if (!pix) { i++; if (extension[i]) goto try_next_extension; } } else { /* even the path does not exist (deleted between two sessions), so set the preferences to the internal theme */ prefs_common.pixmap_theme_path = g_strdup(DEFAULT_PIXMAP_THEME); } } pix_d->pixbuf = pix; } if (!pix_d->pixbuf) { pix_d->pixbuf = gdk_pixbuf_new_from_xpm_data((const gchar **) pix_d->data); if (pix_d->pixbuf) { g_free(pix_d->icon_path); pix_d->icon_path = g_strdup(DEFAULT_PIXMAP_THEME); } } cm_return_val_if_fail(pix_d->pixbuf != NULL, -1); if (pixbuf) *pixbuf = pix_d->pixbuf; /* pixbuf should have one ref outstanding */ return 0; }
MYX_GRT_VALUE * edit_obj(MYX_GRT_VALUE *param, void *data) { MYX_GRT *grt= (MYX_GRT *)data; MYX_GRT_VALUE *editor_list= myx_grt_dict_item_get_by_path(grt, myx_grt_get_root(grt), "/app/editors"); MYX_GRT_VALUE *object; MYX_GRT_VALUE *element; MYX_GRT_VALUE *action_value; int action; if (myx_grt_list_item_count(param) != 3) return make_return_value_error("editObj takes 3 parameters (object, element, action).", ""); object= myx_grt_list_item_get(param, 0); element= myx_grt_list_item_get(param, 1); action_value= myx_grt_list_item_get(param, 2); if (myx_grt_value_get_type(action_value) != MYX_INT_VALUE) return make_return_value_error("last argument of editObj() is the action number", ""); action= myx_grt_value_as_int(action_value); if (editor_list) { const char * object_struct_name= myx_grt_dict_struct_get_name(object); unsigned int i; int rating_best= -1, rating_best_exact= -1; MYX_GRT_VALUE *editor_best= NULL; MYX_GRT_VALUE *editor_best_exact= NULL; // take a look at all available editors for (i= 0; i < myx_grt_list_item_count(editor_list); i++) { MYX_GRT_VALUE *editor= myx_grt_list_item_get(editor_list, i); const char *editor_struct_name= myx_grt_dict_item_get_as_string(editor, "objectStructName"); int editor_rating= myx_grt_dict_item_get_as_int(editor, "rating"); int editor_action= myx_grt_dict_item_get_as_int(editor, "actionId"); if (editor_action == 0 || action == 0 || editor_action == action) { if ((strcmp2(object_struct_name, editor_struct_name) == 0) && (editor_rating > rating_best_exact)) { editor_best_exact= editor; rating_best_exact= editor_rating; } if (myx_grt_struct_is_or_inherits_from(grt, object_struct_name, editor_struct_name) && (editor_rating > rating_best)) { editor_best= editor; rating_best= editor_rating; } } } // if there is an editor for exactly this struct, prefere it over all editors that // edit only parents structs if (editor_best_exact) editor_best= editor_best_exact; if (editor_best) { MYX_GRT_ERROR error; return make_return_value(myx_grt_function_get_and_call(grt, myx_grt_dict_item_get_as_string(editor_best, "moduleName"), myx_grt_dict_item_get_as_string(editor_best, "moduleFunctionName"), 0, param, &error)); } else return make_return_value(0); } else return make_return_value_error("No editors available.", ""); }
int prep (void) /* Check for preprocessor commands */ { int b, c; char *ln; ln = line; while (*(++ln) == '#' || *ln == ' ') /* locate first directive character */ ; if ( ! *ln) /* NULL directive */ return (killine ()); /* fprintf(stderr,"prep - line=%s\n",ln); */ if (strcmp2 (ln, "if ") || strcmp2 (ln, "ifdef ") || strcmp2 (ln, "ifndef ")) { /* fprintf(stderr,"prep - calling doif(%s)\n",ln); */ doif (ln); return (killine ()); } if (strcmp2 (ln, "else")) { doelse (); return (killine ()); } if (strcmp2 (ln, "endif")) { doendif (); return (killine ()); } if (strcmp2 (ln, "elif ")) { doelif (ln); return (killine ()); } if (procsw) { if (strcmp2 (ln, "define ")) { c = getident (ln, 7) + 2; /* get end of identifier */ splittok (ln, c); /* tokenize rest of line */ dodefine (strlen (line), &ln[7] - line); /* store #define info */ /* fprintf(stderr,"PREP (after dodef): line=|%s|\n",line); */ tstdupdef (); /* Check for def duplication and fix */ return (killine ()); /* Discard #define line */ } if (strcmp2 (ln, "include ")) { doinclude (&ln[8]); /* open include file */ return (killine ()); /* Discard #include line */ } if (strcmp2 (ln, "undef ")) { /* fprintf(stderr,"prep - undef found %s\n",ln); */ doundef (&ln[6]); /* remove undef identifier from def table */ /* fprintf(stderr,"prep - doundef done\n"); */ return (killine ()); /* Discard #undef line */ } if (strcmp2 (ln, "error ")) { fprintf (stderr, "User error - %s\n", &ln[6]); /* print error */ return (killine ()); /* Discard #error line */ } if (strcmp2 (ln, "asm")) { for (;;) /* send all following lines through for assembler */ { getln (0); if (eflag) break; if (findstr (1, line, "#endasm")) break; if (cflag) puts ("#2"); else printf ("#pragma asm "); printf ("%s\n", line); } if (eflag && cflag) /* error only in Microware mode (no #endasm) */ doerr (18, 1); return (killine ()); } if (strcmp2 (ln, "pragma ")) { dopragma (ln + 7); return (killine ()); } if (strcmp2 (ln, "line ")) { doline (ln + 5); return (killine ()); } doerr (17, 1); /* Illegal preprocessor directive */ return (killine ()); } }